我正在关注 getting started with create react native app创建我的第一个 react native 应用程序。但我收到以下错误 -
npm start
2:11:42 PM: Starting packager... 2:11:46 PM: Error starting packager: Error: Couldn't start project. Please fix the errors and restart the project. at /xdl/src/Project.js:1039:11 at Generator.next (<anonymous>) at step (/Users/xyz/my-app/node_modules/xdl/build/Project.js:1461:191) at /Users/xyz/my-app/node_modules/xdl/build/Project.js:1461:361 at <anonymous> npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-app@0.1.0 start: `react-native-scripts start` npm ERR! Exit status 1 npm ERR! Failed at the my-app@0.1.0 start script.
此跟踪在文件 Project.js
中引用的代码行 -
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
按照这里的建议 npm ERR! code ELIFECYCLE我尝试执行 npm run clean
和 delete node_modules 和 npm install
。但这也无济于事。
版本详情-
➜ npm -v
5.0.1
➜ node -v
v8.0.0
最佳答案
React 代码应该没问题。
您是否可能将您的项目移动到另一个文件夹? Similar problem on github
尝试以下操作:
- 删除项目根目录中的 node_modules 文件夹
rm -rf node_modules
- 转到项目根目录并运行
npm install
关于node.js - 如何在 npm 启动期间在 Project.js 中解析 'npm ERR! code ELIFECYCLE',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44365238/