node-pre-gyp: npm@5 TypeError: Cannot read property 'version' of null
Looks like using npm 5 we have a problem.
package_json.version at line 262 is undefined and throws at line 270
TypeError: Cannot read property 'version' of null
at Object.module.exports.evaluate (/Users/yvele/repo/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/versioning.js:270:32)
at install (/Users/yvele/repo/node_modules/fsevents/node_modules/node-pre-gyp/lib/install.js:168:31)
at Object.self.commands.(anonymous function) [as install] (/Users/yvele/repo/node_modules/fsevents/node_modules/node-pre-gyp/lib/node-pre-gyp.js:50:37)
at run (/Users/yvele/repo/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp:79:30)
at Object.<anonymous> (/Users/yvele/repo/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp:131:1)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
Main NPM issue:
Related issues:
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 63
- Comments: 16 (2 by maintainers)
Commits related to this issue
- Disallow package-lock for npm5 fsevents compatibility See https://github.com/mapbox/node-pre-gyp/issues/298 for details. — committed to mozilla-services/screenshots by jaredhirsch 7 years ago
- Disallow package-lock for npm5 fsevents compatibility See https://github.com/mapbox/node-pre-gyp/issues/298 for details. — committed to mozilla-services/screenshots by jaredhirsch 7 years ago
- Merge pull request #440 from cvan/do-not-use-package-lock-for-npm5-to-work-around-node-pre-gyp-bug do not use `package-lock.json` (workaround for `node-pre-gyp` bug on npm5: mapbox/node-pre-gyp#298) ... — committed to aframevr/aframe-site by ngokevin 7 years ago
- fix docs to avoid mentioning the deprecated prepublish - refs #291, 71e64118401, https://github.com/mapbox/node-pre-gyp/issues/298#issuecomment-327918111 — committed to mapbox/node-pre-gyp by deleted user 7 years ago
- Adding package-lock.json to npmrc. Temporary fix: [https://github.com/mapbox/node-pre-gyp/issues/298]. — committed to vinsol-spree-contrib/spree-on-react by shubham-vinsol 7 years ago
- Adding package-lock.json to npmrc. Temporary fix: [https://github.com/mapbox/node-pre-gyp/issues/298]. — committed to believe2world/react-spree-bunny by believe2world 7 years ago
- fix docs to avoid mentioning the deprecated prepublish - refs #291, 71e64118401, https://github.com/mapbox/node-pre-gyp/issues/298#issuecomment-327918111 — committed to X-Profiler/node-pre-gyp by deleted user 7 years ago
workaround: Remove the lock file.
rm .\package-lock.jsonI added
package-lock=falseto the.npmrcfile in my repo’s root directory in order to temporarily workaround the issue. Seemed cleaner than adding it to the.gitignore. 😛@borislemke That may work as a temporary solution, but the
package-lock.jsonfile is meant to be committed to source control.If you remove the lock file doesnt it just regenerate it again after running
npm install?I think this is due to npm5 using a URL value for the
versionproperty in package.json files now.There’s a hint in the full error output below:
Specifically, you see:
node-pre-gyp ERR! node-pre-gyp -v vhttps://registry.npmjs.org/node-pre-gyp/-/node-pre-gyp-0.6.34.tgzLooking at the package.json files in my node_modules folder after an npm5 install, I see things like:
So semver.parse is returning null because these aren’t really semantic versioning strings, but urls of resolved packages. Ultimately I’m not sure if this is a node-pre-gyp “bug” that you’d need to add a workaround for, or it’s an npm5 bug. Certainly feels more like an npm bug to me, but then maybe they need/intend for the version value to be a URL for the future.
in my case the
package-lock.jsonfile got included in the project’s commit. When cloning the repo on another machine and doingnpm i, this error would be thrown. We added the lock file to.gitignoreand all works well.Thanks for the report and digging everyone. As the current maintainer of node-pre-gyp my preference here is to:
Thank you @floriantraber for pointing out the removal of package-lock.json. I did that and was still getting the error, but when I removed my node_modules folder and then ran npm install again, It worked. So remove both package-lock.json and node_module folder and ran npm install and that should work.
I am facing the same issue . what do i need to fix it ? Kindly guide. thank you.
https://stackoverflow.com/questions/44462901/how-to-install-latest-angular-cli-using-visual-studio-2017-node-js-interactive-w