简体   繁体   English

NPM完全忽略了全局安装的软件包

[英]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 系统:Mac OS X
Node : 8.3.1 节点:8.3.1
NPM : 5.0.4 NPM:5.0.4

Output for npm list -g --depth=0 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. 当我尝试安装时,首先会提到node-gyp ,它全局安装的,与警告不同。 And after that it fails with node-sass which is also installed globally. 之后,它失败node-sass也是全球的装机量。

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. 我已经在Mac OS npm doctor上重新安装了Node,检查了npm doctor和其他所有内容,但是我完全不知所措。

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. 请注意,这不能解决警告: npm WARN prefer global node-gyp@3.6.2 should be installed with -g但是它允许我再次安装并运行脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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