Npm Errors总结

npm ERR! A complete log of this run can be found in:

Q:

1
2
3
4
npm ERR! Unexpected end of JSON input while parsing near '...hZ3yMhAU8CwbLGBDYZTXS'

npm ERR! A complete log of this run can be found in:
npm ERR! /Users/moyan/.npm/_logs/2019-10-08T01_36_12_540Z-debug.log

A:

1
2
3
4
5
6
7
8
9
10
11
12
13
## 提供的一些解决办法,但是仍没有解决
npm报错,这时需要全局更新npm
npm i
npm g
解决!

或者使用淘宝镜像:
cnpm i
cnpm g
解决!

## 最后看到了一段清除npm缓存的命令,运行之后果然成功了
npm cache clean --force

npm install 报错

Q:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

> fsevents@1.2.9 install /Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents
> node install

node-pre-gyp WARN Using needle for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for fsevents@1.2.9 and node@8.11.3 (node-v57 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/build'
gyp ERR! System Darwin 18.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node" "--module_name=fse" "--module_path=/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64" "--napi_version=3" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v57" "--python=python2.7"
gyp ERR! cwd /Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node --module_name=fse --module_path=/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57 --python=python2.7' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Darwin 18.7.0
node-pre-gyp ERR! command "/usr/local/bin/node" "/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents
node-pre-gyp ERR! node -v v8.11.3
node-pre-gyp ERR! node-pre-gyp -v v0.12.0
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node --module_name=fse --module_path=/Users/moyan/All/GitStorehouse/hxdd/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64 --napi_version=3 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v57 --python=python2.7' (1)

1
2
3
4
5
6
## 没权限的加sudo执行,还是报错

## 方案一 升级npm
npm install -g npm
## 方案二
npm install --unsafe-perm