执行 npm报错 Cannot find module ‘../lib/cli.js‘
报错
/usr/local/node/node-v18.20.4-linux-x64/bin/npm
node:internal/modules/cjs/loader:1143
throw err;
^
Error: Cannot find module '../lib/cli.js'
Require stack:
- /usr/local/node/node-v18.20.4-linux-x64/bin/npm
at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
at Module._load (node:internal/modules/cjs/loader:981:27)
at Module.require (node:internal/modules/cjs/loader:1231:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/usr/local/node/node-v18.20.4-linux-x64/bin/npm:2:1)
at Module._compile (node:internal/modules/cjs/loader:1364:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
at Module.load (node:internal/modules/cjs/loader:1203:32)
at Module._load (node:internal/modules/cjs/loader:1019:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/local/node/node-v18.20.4-linux-x64/bin/npm' ]
}
Node.js v18.20.4
解决办法
原因是从一台电脑直接复制解压后的文件过来的, 重新上传压缩包进行解压即可
tar -Jxf node-v18.20.4-linux-x64.tar.xz