Open watson opened 7 years ago
Here's some more verbose output:
And here's the result of running npm test
just after that:
$ npm test
> test-all-versions@2.4.2 pretest /private/tmp/test-all-versions
> npm prune
up to date in 1.387s
> test-all-versions@2.4.2 test /private/tmp/test-all-versions
> standard && tape test.js
module.js:487
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/private/tmp/test-all-versions/test.js:4:14)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
Just tried to list all dependencies - seems to be worse than just a single dependency:
$ npm ls --depth=0
test-all-versions@2.4.2 /private/tmp/test-all-versions
├── UNMET DEPENDENCY after-all@^2.0.2
├── UNMET DEPENDENCY fresh-require@^1.0.3
├── UNMET DEPENDENCY is-ci@^1.0.10
├── UNMET DEPENDENCY js-yaml@^3.7.0
├── UNMET DEPENDENCY minimist@^1.2.0
├── UNMET DEPENDENCY npm-package-versions@^1.0.0
├── UNMET DEPENDENCY once@^1.4.0
├── UNMET DEPENDENCY resolve@^1.2.0
├── UNMET DEPENDENCY semver@^5.1.0
├── UNMET DEPENDENCY spawn-npm-install@^1.2.0
├── standard@8.6.0
└── tape@4.6.3
npm ERR! missing: after-all@^2.0.2, required by test-all-versions@2.4.2
npm ERR! missing: fresh-require@^1.0.3, required by test-all-versions@2.4.2
npm ERR! missing: is-ci@^1.0.10, required by test-all-versions@2.4.2
npm ERR! missing: js-yaml@^3.7.0, required by test-all-versions@2.4.2
npm ERR! missing: minimist@^1.2.0, required by test-all-versions@2.4.2
npm ERR! missing: npm-package-versions@^1.0.0, required by test-all-versions@2.4.2
npm ERR! missing: once@^1.4.0, required by test-all-versions@2.4.2
npm ERR! missing: resolve@^1.2.0, required by test-all-versions@2.4.2
npm ERR! missing: semver@^5.1.0, required by test-all-versions@2.4.2
npm ERR! missing: spawn-npm-install@^1.2.0, required by test-all-versions@2.4.2
It looks like that it actually only installed the devDependencies
:
...
"dependencies": {
"after-all": "^2.0.2",
"fresh-require": "^1.0.3",
"is-ci": "^1.0.10",
"js-yaml": "^3.7.0",
"minimist": "^1.2.0",
"npm-package-versions": "^1.0.0",
"once": "^1.4.0",
"resolve": "^1.2.0",
"semver": "^5.1.0",
"spawn-npm-install": "^1.2.0"
},
"devDependencies": {
"standard": "^8.6.0",
"tape": "^4.6.3"
},
...
Cannot reproduce with npm@5.0.3
:
Just upgraded to v5.0.3 - getting the same error. Must be something weird with my environment then
I also get the same with 5.0.3. npm complains about a lot of missing deps
I'm using nvm - not sure if that's an issue?
I just copied the cloned package.json into a fresh tmp directory and ran npm install
again. This time it worked fine:
$ npm i
npm notice created a lockfile as package-lock.json. You should commit this file.
added 275 packages in 10.748s
$ npm ls --depth=0
test-all-versions@2.4.2 /private/tmp/foo
├── after-all@2.0.2
├── fresh-require@1.0.3
├── is-ci@1.0.10
├── js-yaml@3.8.4
├── minimist@1.2.0
├── npm-package-versions@1.0.0
├── once@1.4.0
├── resolve@1.3.3
├── semver@5.3.0
├── spawn-npm-install@1.2.0
├── standard@8.6.0
└── tape@4.6.3
Ok, now I know what's going on. Apparently the package-lock.json
file that was autogenerated the first time I ran npm install
after cloning was missing a lot of the modules. And upgrading to npm@5.0.3 obviously didn't change anything at this point because it would still use the old lock file. I'll just try to see if I can figure out why the lock file got corrupted
Ok, now I can also successfully reproduce it. The procedure is as follows:
git clone git@github.com:watson/test-all-versions.git
cd test-all-versions
npm test
(notice that we run test before installing modules, this will create a stub package-lock.json file)npm install
(notice that this only installs 178 modules instead of the correct 275 modules)npm ls --depth=0
After running the last command you should now see that only devDependencies
have been installed
@KenanY can you try again with the new 5 point process I posted above?
Just boiled it down to a self contained test:
{
"name": "foo",
"version": "1.0.0",
"dependencies": {
"semver": "*"
},
"devDependencies": {
"ci-info": "*"
}
}
npm prune
inside that directory. A stub package-lock.json file will now be created:
{
"name": "foo",
"version": "1.0.0",
"lockfileVersion": 1
}
npm install
(only ci-info
is now installed and package-lock.json will only contain that module)Note that the actual depended upon modules doesn't matter. I just chose two simple modules without any sub-dependencies in this example
We're closing this issue as it has gone seven days without activity and without being labeled. If we haven't even labeled in issue in seven days then we're unlikely to ever read it.
If you are still experiencing the issue that led to you opening this or this is a feature request you're still interested in then we encourage you to open a new issue. If this was a support issue, you may be better served by joining package.communty and asking your question there.
For more information about our new issue aging policies and why we've instituted them please see our blog post.
module.js:487 throw err; ^
Error: Cannot find module 'safe-buffer'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.
I'm opening this issue because:
What's going wrong?
npm 5 doesn't always install all dependencies.
For now I have only seen this in one repo: https://github.com/watson/test-all-versionsHow can the CLI team reproduce the problem?
git clone git@github.com:watson/test-all-versions.git
cd test-all-versions
npm i
npm test
It should now fail withError: Cannot find module 'semver'
.And if I look innode_modules
it's not thereAn updated guide on how to reproduce the error have been posted as a comment: https://github.com/npm/npm/issues/17061#issuecomment-306870678
supporting information:
npm -v
prints:updated to5.0.0
5.0.3
node -v
prints:v8.0.0
npm config get registry
prints:https://registry.npmjs.org/