react-native: react-native-cli is not compatible with npm@5

Is this a bug report?

Yes

Have you read the Bugs section of the Contributing to React Native Guide?

Yes

Environment

  1. react-native -v:
react-native-cli: 2.0.1
react-native: 0.45.1
  1. node -v:
v8.1.1
  1. npm -v:
5.0.4
  1. yarn --version (if you use Yarn): 0.23.2

Then, specify:

  1. Target Platform (e.g. iOS, Android): Whatever the result of yarn start is
  2. Development Operating System (e.g. macOS Sierra, Windows 10): macOS Sierra
  3. Build tools (Xcode or Android Studio version, iOS or Android SDK version, if relevant): Not relevant

Steps to Reproduce

Perform the first four steps outlined in the Getting Started (https://facebook.github.io/react-native/docs/getting-started.html) guide with a totally fresh React Native project.

  1. npm install -g create-react-native-app
  2. create-react-native-app AwesomeProject
  3. cd AwesomeProject
  4. npm start

Expected Behavior

I thought a dev server would run, or I would see the QR code mentioned in the Getting Started guide. I would expect react-native to be compatible with npm 5.0.4 or give instructions as to how to downgrade (not ideal). I wouldn’t expect it to just outright break.

Actual Behavior

➜  /Users/foo/TestApp npm start

> TestApp@0.1.0 start /Users/foo/TestApp
> react-native-scripts start

1:54:47 PM: Starting packager...
***ERROR STARTING PACKAGER***

Error: You are using npm version 5.0.4. Please use an npm version that is >= 3.0.0 and < 5.0.0.
1:54:47 PM: Error starting packager: Error: Couldn't start project. Please fix the errors and restart the project.
    at /xdl/src/Project.js:1038:11
    at Generator.next (<anonymous>)
    at step (/Users/foo/TestApp/node_modules/xdl/build/Project.js:1468:191)
    at /Users/foo/TestApp/node_modules/xdl/build/Project.js:1468:361
    at <anonymous>
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! TestApp@0.1.0 start: `react-native-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the TestApp@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/foo/.npm/_logs/2017-06-28T20_54_47_593Z-debug.log

Reproducible Demo

Explained above.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 28
  • Comments: 34 (6 by maintainers)

Most upvoted comments

You can downgrade npm with: npm install -g npm@4

Quoting @johndanek again,

I would expect react-native to be compatible with npm 5.0.4 or give instructions as to how to downgrade (not ideal)

We understand that react-native or react-native-cli might not be responsible for the bug, but as the naive users, we do expect it to work gracefully.

It’d be great if someone can explain the issue, rather than just telling us to downgrade. It would not only help us understand the issue, but we might be able to contribute as well. Even if can’t, we’ll be able to raise the issue in the right repository.

This appears to be an issue with npm 5, as the error states. You can try downgrading to npm 4.

I just installed yarn & everything worked like a charm brew install yarn

Downgrade to npm 4 with this commad npm install -g npm@4

downgrade to npm version 4. Works for me!

+1

npm i -g npm@4

And there I thought that there is a new way of setting up a React Native project that is less painful; Turns out create-react-native-app will not work out of the box with the latest software and suggests using yarn (which does not work in parity with npm for git based dependencies)…

And now if you try to start a new project using the old way (react-native init) it will out right brake as well. See this: https://github.com/facebook/react-native/issues/14843

So really, right now there is no way to develop apps on React Native, unless you already have an older project started; that will probably have the upgrade issues of it own as so many of us have experienced.

You got us hooked, now please make this work as expected for once! 😄

Doesn’t change the fact that new users cannot trust the getting started guide…

If you cannot downgrade npm for some reason, install yarn.

@ankitpopli1891 I would start by removing the npm version check, and running the test suites and resolving any issues that may pop up. I’m sure the community would appreciate a PR that removes any issues with npm@5.

A newer version of npm@5 may work as well. Try using npm 5.1.0 for example.

React Native is the only reason I still have yarn installed.

EDIT: Uninstalled already. As of npm@5.7.1, everything is working fine.

npm 5.8.0 has no issue as well

@avinashwigroup npm install npm -g

I do understand that I can use yarn. But if that’s mandatory then perhaps the getting started directions should not instruct to use npm - which doesn’t work.

I upgraded to npm 5.7.1 but still get the following after create-react-native-app, Step 4 (npm start) :

    npm ERR! missing script: start

npm ERR! A complete log of this run can be found in:
npm ERR!     /...-debug.log