[Packager] Packager does not start after upgrading to NPM 3.0 beta
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.
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.
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!
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
@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!
+1 for this issue. require statements should be updated to not include npm packages via relative paths.
+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.
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.
Another +1 for this issue. I'm on npm 3.3.3 and node 4.1.0.
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.
+1. Same on node 4.0.0 and npm 3.3.3
@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?
One way to work around this temporarily is to downgrade npm by running npm install -g 'npm@<3'.
+1. This is pretty troublesome.
The packager will be moved out into its own repo in the near future, and supporting npm 3 can happen then.
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
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.
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
+1
+1
+1