6

I was following the getting started with create react native app to create my first react native application. But I am getting the following error -

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.

The line of code this trace is referring to in the file 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"); }); }; }

As suggested here npm ERR! code ELIFECYCLE I've tried to do a npm run clean and delete node_modules and npm install. But that didn't help either.

Version details -

➜ npm -v
 5.0.1

➜ node -v
v8.0.0
Naman
  • 27,789
  • 26
  • 218
  • 353

6 Answers6

14

The React code should be fine.

Did you maybe move your project to another folder? Similar problem on github

Try the following:

  • Remove your node_modules folder in your project root rm -rf node_modules
  • Go to your project root and run npm install
Tobias Ernst
  • 4,214
  • 1
  • 32
  • 30
4

I wouldn't claim to entirely understand the solution. I think it had something to do with either incorrect addresses recorded to navigate node_modules, or it may have been my version of watchman was outdated or corrupted.

I fixed the issue by reinstalling watchman and deleting/recreating the node_modules and package-lock.json files.

npm cache clean --force

rm -rf node_modules

rm -rf package-lock.json

brew uninstall watchman

npm r -g watchman

npm install watchman

yarn

npm install

react-native link

npm start

Some of the steps might be expendable but it took me a long time so I wanted it to be watertight.

Good luck.

Adam Durey
  • 61
  • 2
2

Date - 12 June, 2017

Just an FYI one liner -

Seems like npm5 is not stable yet. As mentioned by @jit in the comments. The problem was resolved after reverting to npm 4.6.1

npm install -g npm@4.6.1
Naman
  • 27,789
  • 26
  • 218
  • 353
  • Note - As a resolution for this is proposed with version npm5. Would mark that as an answer. By that time, hope this helps people trying things out. – Naman Jun 12 '17 at 04:44
  • is possible to use npm 4.6.1 with any version of node? by example node 4, 5 , 6 or 7. I dont believe that you can change your npm version is that is not related to node version... – stackdave Aug 20 '17 at 17:31
1

I tried all the above steps but the thing that work for me is to delete the "node_module" folder in home directory "C:\Users\musabarif\node_modules"

Make sure you have not installed something accidentally in your Home folder.

Musab
  • 1,067
  • 12
  • 12
0

First of all check the Error in Red colored Text try to resolve that particular error and if any of above things didn't work then follow the following steps:

  1. Create a .env file in your Project folder

  2. Write SKIP_PREFLIGHT_CHECK=true in the file

  3. Save the file

  4. Try to run the project using npm start

Anthony
  • 3,595
  • 2
  • 29
  • 38
-1

I just changed the environment variable to c:\windows\system32 and it worked.

Steps to do so are:

  1. Go to the control panel
  2. Click on System
  3. Choose Advanced System Settings
  4. In the environment variables change the PATH to c:\windows\system32
BahaEddine Ayadi
  • 987
  • 9
  • 20
  • 1
    I don't see anything to indicate this could help. In fact, it would likely do more harm than good, as following those instructions as given would end up removing other directories from PATH, which might be needed for other things (including `npm`). Did you mean to post this on a different question? – flarn2006 Aug 17 '20 at 00:52