react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Packager] Packager does not start after upgrading to NPM 3.0 beta

Open frostney opened this issue 11 years ago • 49 comments

After upgrading to NPM 3.0 beta (https://github.com/npm/npm/releases/tag/v3.0.0), I re-installed the node_modules through npm install in my React Native project. Everything showed up in the file system, but after calling npm start I get the error:

Could not find dependencies.
Ensure dependencies are installed - run 'npm install' from project root.

No matter how often I call npm install and npm start, the error persists. This happens for me with both 0.6.0 and 0.7.0-rc.

frostney avatar Jun 26 '15 15:06 frostney

This happens because the packager is looking for react-native's dependencies in its own node_modules directory. In npm 3, all dependencies install flat in the top level node_modules.

https://github.com/facebook/react-native/blob/master/packager/packager.js#L18

I'd love to start using npm3 - will look into a PR.

jsierles avatar Jun 28 '15 10:06 jsierles

This happens for 0.8.0-rc as well. I thought NPM 3.0.x was needed for the latest release. Surprised to find there are issues!

hokster7 avatar Jul 18 '15 09:07 hokster7

I just had this issue with react-native 0.6.0 and npm 2.13.0. The issue went away by upgrading to react-native 0.7.1 but there's probably a simpler solution

tachim avatar Jul 21 '15 01:07 tachim

@fatuhoku - not sure where you read that, npm 3 is not required for the new release, iojs is :smile:

We don't support npm 3 yet, help from the community on that would be great!

brentvatne avatar Jul 21 '15 01:07 brentvatne

+1 for this issue. require statements should be updated to not include npm packages via relative paths.

EvHaus avatar Aug 19 '15 17:08 EvHaus

+1 hit this too would a simple require check be good enough ? A simple way to detect this would be to try to require some dep and throw the error if it was missing.

lightsofapollo avatar Aug 29 '15 23:08 lightsofapollo

Its the framework trying to be too smart. These lines are merely checking to see if node_modules is present. It doesn't need to do this check. If a dependency isn't there then require will throw an error. Could always monkey patch require to throw that message if the module isn't found.

eddiemonge avatar Sep 15 '15 20:09 eddiemonge

Another +1 for this issue. I'm on npm 3.3.3 and node 4.1.0.

stephen304 avatar Sep 18 '15 17:09 stephen304

I've been using my Pull Request since I submitted it with no problems so far. It's a simple seeming change so hopefully they can merge it soon and be done with this.

require statements should be updated to not include npm packages via relative paths

Its not even that complicated since it already does that. Like I said, it merely tests for node_modules at a specific location, doesn't even save or use it from that location that I can tell.

eddiemonge avatar Sep 18 '15 18:09 eddiemonge

+1. Same on node 4.0.0 and npm 3.3.3

Jarema avatar Sep 18 '15 19:09 Jarema

@eddiemonge I'm not sure how to use that PR because I'm not sure where the react-native files are... I should be able to just edit the matching file right?

stephen304 avatar Sep 18 '15 20:09 stephen304

One way to work around this temporarily is to downgrade npm by running npm install -g 'npm@<3'.

sethwklein avatar Sep 19 '15 03:09 sethwklein

+1. This is pretty troublesome.

alkhe avatar Sep 20 '15 18:09 alkhe

The packager will be moved out into its own repo in the near future, and supporting npm 3 can happen then.

ide avatar Sep 20 '15 22:09 ide

Yeah, the resolution algorithm of the packager needs to be upgraded for npm 3. Also, sadly npm install takes 3x more time for react-native :( https://github.com/npm/npm/issues/8826#issuecomment-141818982

vjeux avatar Sep 21 '15 02:09 vjeux

I've tested this on npm 3 and looks like the dependency resolution system works fine. I'll remove the check that makes packager.sh fail on npm 3 (will be available next time we sync). Other than that doesn't seem there's any actionable item here.

martinbigio avatar Sep 21 '15 21:09 martinbigio

Hi Seems that this is still not working with Node 4 and NPM 3. Can you please let us know when this is fixed? Cheers Bernd

BerndWessels avatar Sep 23 '15 10:09 BerndWessels

+1

farzd avatar Sep 25 '15 12:09 farzd

+1

leaxoy avatar Sep 25 '15 21:09 leaxoy

+1

piotrblasiak avatar Sep 26 '15 00:09 piotrblasiak