npm / npm

This repository is moving to: https://github.com/npm/cli
http://npm.community
17.53k stars 3.02k forks source link

Install failure with local dependencies #17149

Open tomciopp opened 7 years ago

tomciopp commented 7 years ago

I'm opening this issue because:

What's going wrong?

I'm attempting to upgrade from v4.6.1 to v5.0.3 and am running into issues with local dependencies in the phoenix framework. Everything works as expected when using 4.6.1 however when I run npm install I receive a ENOPACKAGEJSON error when on 5.0.3. Based on this PR it looks like there are some breaking changes regarding usage of file specifiers but I cannot find any documentation on any changes I would need to make on my end.

How can the CLI team reproduce the problem?

https://gist.github.com/tomciopp/64378007510b2f6a15d2f11824ccd512

supporting information:

jcald1 commented 7 years ago

Same here. npm 4 works for me but 5.0.3 fails. Here are my details:

I'm running Node 6.9.1 on Ubuntu and npm 5.0.3.
I started off by:

npm cache clean --force
rm -rf ~/.node-gyp
rm -rf ~/.npm
node clean -xfd #at the root directory

Then

cd /usr/apps/myapps/nodejs/MyApp
npm install

Everything installed with no warnings.

weblogic@weblogic-VirtualBox:/usr/apps/myapps/nodejs/MyApp$ npm start --verbose
npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   'start',
npm verb cli   '--verbose' ]
npm info using npm@5.0.3
npm info using node@v6.9.1
npm verb run-script [ 'prestart', 'start', 'poststart' ]
npm info lifecycle MyAppService@0.0.1~prestart: MyAppService@0.0.1
npm info lifecycle MyAppService@0.0.1~start: MyAppService@0.0.1

> MyAppService@0.0.1 start /usr/apps/myapps/nodejs/MyApp
> node index.js --NODE_CONFIG_DIR=../configaitc/MyApp-hits

module.js:471
    throw err;
    ^

Error: Cannot find module 'lodash'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/apps/myapps/nodejs/secure-bull/node_modules/ioredis/lib/redis.js:3:9)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
npm verb lifecycle MyAppService@0.0.1~start: unsafe-perm in lifecycle true
npm verb lifecycle MyAppService@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/apps/myapps/nodejs/MyApp/node_modules/.bin:/opt/java/jdk1.8.0_91/bin:/opt/java/jdk1.8.0_91/bin:/opt/java/jdk1.8.0_91/jre/bin:/usr/apps/python/Python-2.7.5:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/apps/node/latest/bin:/usr/apps/redis/latest/bin:/bin:/bin:/opt/apache-maven-3.3.9/bin:/opt/eclipse/bin:/opt/HP_Fortify/HP_Fortify_SCA_and_Apps_16.20/bin:/usr/apps/das/src/das_rtc/scripts-startapps:/usr/apps/das/src/das_rtc/scripts-fortify
npm verb lifecycle MyAppService@0.0.1~start: CWD: /usr/apps/myapps/nodejs/MyApp
npm info lifecycle MyAppService@0.0.1~start: Failed to exec start script
npm verb stack Error: MyAppService@0.0.1 start: `node index.js --NODE_CONFIG_DIR=../configaitc/MyApp-hits`
npm verb stack Exit status 1
npm verb stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at EventEmitter.emit (events.js:191:7)
npm verb stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack     at emitTwo (events.js:106:13)
npm verb stack     at ChildProcess.emit (events.js:191:7)
npm verb stack     at maybeClose (internal/child_process.js:877:16)
npm verb stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid MyAppService@0.0.1
npm verb cwd /usr/apps/myapps/nodejs/MyApp
npm verb Linux 3.13.0-113-generic
npm verb argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--verbose"
npm verb node v6.9.1
npm verb npm  v5.0.3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! MyAppService@0.0.1 start: `node index.js --NODE_CONFIG_DIR=../configaitc/MyApp-hits`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the MyAppService@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]

/usr/apps/myapps/nodejs/MyApp/node_modules/secure_bull

has a symlink to ../secure-bull, which is

/usr/apps/das/das_rtc/nodejs/secure-bull

.

/usr/apps/das/das_rtc/nodejs/secure-bull/node_modules

exists and has modules inside of it including ioredis, but does not have lodash. secure-bull doesn't use lodash directly.

/usr/apps/myapps/nodejs/secure-bull/node_modules/ioredis/package.json

has "lodash": "^4.8.2".

/usr/apps/myapps/nodejs/secure-bull/node_modules/ioredis/node_modules

does not exist.

metasansana commented 7 years ago

I am having similar issues with a scoped package. Stayed up hours trying to fix.

For anyone who is running into this use a postinstall script as a workaround if you can.

jcald1 commented 7 years ago

@metasansana, you can try npm version 4.

iarna commented 7 years ago

Can you all try again with the just released npm@5.1? We fixed a bunch of bugs in it and it may have improved things for you. (Tbh, it's not clear to me either just yet if npm@5 broke something here or if it was the intended change in behavior. But I wouldn't expect it to break things like this.)

jcald1 commented 7 years ago

@iarna, I tested again with 5.1 and I still see the issue. In my previous response (which I deleted), I had only tested installing, not running the application.

metasansana commented 7 years ago

I am on version 5.4. Still running into this.

jcald1 commented 6 years ago

@metasansana, can you try again with v5.5.1? Seems to be working for me, at least when I tried to recreate the issue with new code.

metasansana commented 6 years ago

@jcald1 Just tried appears to be working now. Good job @npm team.

jcald1 commented 6 years ago

@tomciopp, want to retry with v5.5.1+ and close if it works for you?