简体   繁体   中英

NPM is completely ignoring globally installed packages

I'm having a problem with installing packages locally, where globally installed packages are available. There seems to be a problem with the include path, but I am not sure what this is causing.

System : Mac OS X
Node : 8.3.1
NPM : 5.0.4

Output for npm list -g --depth=0

/usr/local/lib
+-- node-gyp@3.6.2
+-- node-sass@4.5.3
+-- npm@5.0.4
`-- npm-check@5.4.4

When I'm trying to install it first mentions node-gyp which is installed globally, unlike the warning. And after that it fails with node-sass which is also installed globally.

jurriendokter$ npm install
npm WARN prefer global node-gyp@3.6.1 should be installed with -g

> node-sass@4.5.2 install /Users/jurriendokter/Development/holland-toolkit/node_modules/node-sass
> node scripts/install.js

module.js:487
    throw err;
    ^

Error: Cannot find module 'extend'
    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> (/Users/jurriendokter/Development/holland-toolkit/node_modules/node-sass/node_modules/request/index.js:17:29)
    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)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@https://registry.npmjs.org/node-sass/-/node-sass-4.5.2.tgz (node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.5.2 install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 291 packages in 7.829s

I have reinstalled node on mac osx, checked npm doctor and everything, but I'm at a total loss.

How can I fix this?

I managed to fix this using the following procedure.

  • npm cache clear --force
  • rm -rf node_modules
  • rm package-lock.json
  • npm install
  • npm update

Mind that this does not solve the warning: npm WARN prefer global node-gyp@3.6.2 should be installed with -g but it allows me to install and run my scripts again.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM