Cannot find module ‘../lib/utils/unsupported.js‘ npm重安装失败解决windows linux

866 阅读1分钟

windows

+ npm install
internal/modules/cjs/loader.js:605
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:659:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at /usr/local/node-v11.4.0-linux-x64/bin/npm:19:21
    at Object.<anonymous> (/usr/local/node-v11.4.0-linux-x64/bin/npm:153:3)
    at Module._compile (internal/modules/cjs/loader.js:723:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
Build step 'Execute shell' marked build as failure

卸载node,删除C:\Users\电脑用户名\AppData\Roaming下npm 和npmcatch文件夹,重新安装node即可
问题是 npm没安装好,需要清理环境中留存文件.

在linux中也是

由于我是从其它服务器拷贝的node文件夹,经过度娘提示,重新下载tag包文件再解压,问题解决,步骤同安装npm一样

备注:

错误信息

Running command - failed![ERROR] An error occurred while running npm install (exit code 1):

    module.js:471
        throw err;
        ^

    Error: Cannot find module '../lib/utils/unsupported.js'
        at Function.Module._resolveFilename (module.js:469:15)
        at Function.Module._load (module.js:417:25)
        at Module.require (module.js:497:17)
        at require (internal/module.js:20:19)
        at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
        at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:79:3)
        at Module._compile (module.js:570:32)
        at Object.Module._extensions..js (module.js:579:10)
        at Module.load (module.js:487:32)
        at tryModuleLoad (module.js:446:12)

在Mac OS X(10.12.6)上,我通过执行以下操作解决了此问题:

brew uninstall --force node
brew install node

然后我得到一个错误抱怨节点postinstall失败,并重新运行 brew postinstall node

然后我收到一个错误:

permission denied @ rb_sysopen /usr/local/lib/node_modules/npm/bin/npx

我解决了这个错误:

sudo chown -R $(whoami):admin /usr/local/lib/node_modules

我收到了类似的错误,现在让它正常工作。

首先确保您拥有最新版本

brew update

删除以前的节点实例:

brew uninstall node

然后重新安装最新版本:

brew install node

然后确保它已符号链接到/ usr / local(如果还没有)。您将收到错误消息,告知您完成此步骤。

brew link --overwrite node 

还提供了有关如何安装/升级节点的更多详细信息。