通过npm安装cnpm,一直提示警告,WARN如下:
npm WARN deprecated socks@1.1.10: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1
我没有管这个警告,接着向下执行,然后就报错了~,报错信息如下:
npm ERR! Linux 4.15.0-36-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "cnpm" "--registry=https://registry.npm.taobao.org"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! path /usr/local/lib/node_modules/.staging/ansi-regex-5d5795cb
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/ansi-regex-5d5795cb' -> '/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/ansi-regex'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/ansi-regex-5d5795cb' -> '/usr/local/lib/node_modules/cnpm/node_modules/npm/node_modules/ansi-regex'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! /npm-debug.log
然后我尝试网上找的解决方法:
npm set registry https://registry.npm.taobao.org
npm set disturl https://npm.taobao.org/dist
npm cache clean --force
然后没有解决,我就接着尝试下面的方法:
cnpm install cnpm@5.3.0
安装提示如下:
Installed 1 packages
✔ Run 0 scripts
deprecate cnpm@5.3.0 › npm-request@1.0.0 › urllib@2.31.2 › proxy-agent@2.3.1 › socks-proxy-agent@3.0.1 › socks@^1.1.10 If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0
Recently updated (since 2018-11-21): 4 packages (detail see file /node_modules/.recently_updates.txt)
✔ All packages installed (248 packages installed from npm registry, used 5s(network 5s), speed 2.36MB/s, json 228(451.11kB), tarball 10.19MB)
然后执行cnpm -v,提示如下:
cnpm@6.0.0 (/usr/local/lib/node_modules/cnpm/lib/parse_argv.js)
npm@6.4.1 (/usr/local/lib/node_modules/cnpm/node_modules/npm/lib/npm.js)
node@8.10.0 (/usr/bin/node)
npminstall@3.16.0 (/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js)
prefix=/usr/local
linux x64 4.15.0-36-generic
registry=https://registry.npm.taobao.org
完美解决问题,感谢各位~