当我运行“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)

当前回答

这是一个关于从你的计算机操作系统中移除节点的有用视频和博客文章。这是一种不同的删除方法,基于您最初安装节点的方式(brew vs.从https://nodejs.org/en/下载的二进制文件)

if you installed node with Homebrew then brew uninstall node will work. Verify that with running a node -v command in your terminal. Otherwise and if you have installed the binary file from nodeJS's websitethen you have to run this command in your terminal: sudo rm -rf /usr/local/{bin/{node,npm},lib/node_modules/npm,lib/node,share/man/*/node.*}. Again, verify that with running a node -v command. In both cases, successful removal of node should result in bash not recognizing what node is if it is completely removed

其他回答

尝试了以上所有/旧的brew安装答案,没有一个是为我的笔记本电脑工作。

只有下面的方法可以解决我的问题。

1)执行如下命令:

sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node      

2)进入Node.js官方网站https://nodejs.org/en/download/current/下载最新安装包。

3)再次运行你的npm命令,它应该不再有任何错误。

此方法适用于macOS Mojave Version 10.14.4。

只需遵循三个步骤;

强制清除npm缓存: NPM缓存清理-f 使用npm全局安装n个包: NPM install -g 从以下三个选项中任意一个安装: A. sudo n stable(获取稳定版) B. sudo n latest(获取节点的最新版本) C. sudo n X.X.X(获取节点的具体版本)

我通过运行下面的命令解决了这个问题

NVM安装节点——reinstall-packages-from=node

https://nodejs.org/en/

只需从官网下载节点,这对我有用!:)

尝试删除/usr/local/lib/node_modules/npm并重新安装node。这应该有用。

在MacOS上使用Homebrew:

sudo rm -rf /usr/local/lib/node_modules/npm
brew reinstall node