Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
frostney opened this issue Jun 26, 2015 · 49 comments
Closed

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

frostney opened this issue Jun 26, 2015 · 49 comments
Assignees
Labels
Resolution: Locked This issue was locked by the bot.

Comments

@frostney
Copy link
Contributor

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.

@brentvatne brentvatne changed the title Packager does not start after upgrading to NPM 3.0 beta [Packager] Packager does not start after upgrading to NPM 3.0 beta Jun 27, 2015
@jsierles
Copy link
Contributor

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.

@fatuhoku
Copy link

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!

@tachim
Copy link

tachim commented Jul 21, 2015

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

@brentvatne
Copy link
Collaborator

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

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

@EvHaus
Copy link

EvHaus commented Aug 19, 2015

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

@lightsofapollo
Copy link

+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.

@eddiemonge
Copy link
Contributor

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.

@stephen304
Copy link

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

@eddiemonge
Copy link
Contributor

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.

@Jarema
Copy link

Jarema commented Sep 18, 2015

+1. Same on node 4.0.0 and npm 3.3.3

@stephen304
Copy link

@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?

@sethwklein sethwklein mentioned this issue Sep 19, 2015
@sethwklein
Copy link

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

@alkhe
Copy link

alkhe commented Sep 20, 2015

+1. This is pretty troublesome.

@ide
Copy link
Contributor

ide commented Sep 20, 2015

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

@vjeux
Copy link
Contributor

vjeux commented Sep 21, 2015

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 :( npm/npm#8826 (comment)

@martinbigio
Copy link
Contributor

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.

@BerndWessels
Copy link
Contributor

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

@farzd
Copy link

farzd commented Sep 25, 2015

+1

2 similar comments
@leaxoy
Copy link

leaxoy commented Sep 25, 2015

+1

@piotrblasiak
Copy link

+1

@faurehu
Copy link

faurehu commented Sep 26, 2015

I have node v4.0 and npm v3.3.4 and this issue also affects me.

@mschwartz
Copy link

+1

1 similar comment
@FaridSafi
Copy link

+1

@vjeux vjeux reopened this Sep 28, 2015
@koi646
Copy link

koi646 commented Sep 28, 2015

+1

@ts-ign0re
Copy link

solved this problem with

npm i react-native@0.11.3
npm rebuild

@juicemia
Copy link

+1

@nashpro I tried that, still got the same error. Just to confirm here's the output of npm list react-native:

myapp@0.0.1 /Users/hugo/src/myapp
└── react-native@0.11.3 

Running node 4.1.1 with npm 3.3.4

@oguzbilgic
Copy link

+1

1 similar comment
@bluesea
Copy link

bluesea commented Sep 30, 2015

+1

@ghost
Copy link

ghost commented Sep 30, 2015

same story, fixed it by downgrading npm to version 2.14.6

@tuanmai
Copy link

tuanmai commented Sep 30, 2015

+1

@ogonbat
Copy link

ogonbat commented Sep 30, 2015

same story
i have update to npm 3 and have the error
i have downgraded npm to npm@2.14.6 and still have the same error
this is the react native version
react-native@0.11.4
and node 4.1.1

have some solution?

@juicemia
Copy link

I can confirm @didierstockmans fix works. I downgraded npm to 2.14.6 and ran it without issue.

I then upgraded to react-native 0.11.4 and it still works. Still running node 4.1.1.

@eddiemonge
Copy link
Contributor

Downgrading is not a fix for this specific problem. There is a fix in daba142 but it hasn't been released yet. You could install master from this repo and use that

@mkonicek
Copy link
Contributor

daba142 will go out in 0.13 soon.

@juicemia
Copy link

@eddiemonge sorry I meant work around. Lol.

@grabbou
Copy link
Contributor

grabbou commented Nov 12, 2015

@mkonicek unfortunately it's not the only issue. It introduces naming collisions because it takes react-tools from some packages (e.g. immutable, ^0.11.0) and puts it in the root node_modules which conflicts with react-native/node_modules/react-tools. Not sure if there's any workaround to this issue apart from downgrading, which I don't like because of peerDependencies.

@mkonicek
Copy link
Contributor

Interesting, maybe @spicyj might know about react-tools?

@sophiebits
Copy link
Contributor

immutable lists react-tools only as a dev dependency so npm install immutable won't install it and you shouldn't need it to use immutable:

https://github.com/facebook/immutable-js/blob/5138e1d37daa63c03142ef2e5a8b2076c250311e/package.json#L50

@grabbou
Copy link
Contributor

grabbou commented Nov 12, 2015

Ok, fair enough :) Might be coming from a different package then. I definitely don't get the npm3 system behind node_modules structure, because even if I do rm -rf ./node_modules/react-tools - it still works.

@sophiebits
Copy link
Contributor

(Eventually RN will depend on react directly and this won't be an issue even if you install react-tools.)

@mkonicek
Copy link
Contributor

👍 nice!

@ide
Copy link
Contributor

ide commented Nov 19, 2015

This works with simple RN projects. External npm packages might cause trouble -- so if you encounter issues please test with a basic RN project with no extra dependencies.

@ide ide closed this as completed Nov 19, 2015
@symmetriccurve
Copy link

Downgrading the npm@2.14.6 works for me.

@jdk89757
Copy link

PATH: [Your Project]/node_modules/react-native/package/packager.js
SOLUTION: add'../..' & delete 'node_modules',
CODE:if (!fs.existsSync(path.resolve(__dirname, '../..', ''))) {
console.log(
'\n' + path.resolve(__dirname, '../..', '') +
'Could not find dependencies.\n' +
'Ensure dependencies are installed - ' +
'run 'npm install' from project root.\n'
);
process.exit();
}

@austinkelleher
Copy link

+1

1 similar comment
@thibautsabot
Copy link

+1

@facebook facebook locked as resolved and limited conversation to collaborators Jul 22, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Jul 22, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests