当我运行“Ionic start project name”时,我总是得到这个错误消息:

错误消息

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)

当前回答

在fedora 27上,我这样解决了这个问题:

sudo rm -f  /usr/local/lib/node_modules/npm
sudo dnf reinstall nodejs

其他回答

在Mac OS X(10.12.6)上,我通过以下方法解决了这个问题:

brew uninstall --force node
brew install node

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

然后我得到一个错误:

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

我通过以下方法解决了这个错误:

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

现在我不会再得到这个错误了。

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

首先确保你有最新的版本

brew update

删除之前的node实例:

brew uninstall node

然后重新安装最新版本:

brew install node

然后确保它被符号链接到/usr/local(如果还没有)。您将得到一个错误,让您知道要完成这一步。

brew link --overwrite node 

关于如何安装/升级节点的更多详细信息也可用。

在Windows上:

移除~/AppData/Roaming目录下的npm文件夹

我通过删除node_modules,然后重新安装节点稳定版本来解决这个问题。

我通过混合安装/更新方法得到了这个错误:通过从网站下载包安装节点,后来我使用brew更新。

我通过卸载brew版本来修复:

酿造卸载——忽略依赖项节点

然后我回到节点网站,通过包管理器下载并安装:https://nodejs.org/en/download/ 出于某种原因,再多的尝试通过brew重新安装都不起作用。