node.js 错误:在使用 Ionic 时找不到模块“../lib/utils/unsupported.js”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44363066/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: Cannot find module '../lib/utils/unsupported.js' while using Ionic
提问by inxoy
I always get this error message when I run "Ionic start project name":
当我运行“Ionic start project name”时,我总是收到此错误消息:
Error message
错误信息
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)
回答by Vincent Ducastel
Try to remove /usr/local/lib/node_modules/npmand reinstall node again. This should work.
尝试/usr/local/lib/node_modules/npm再次删除并重新安装节点。这应该有效。
On MacOS with Homebrew:
在带有Homebrew 的MacOS 上:
sudo rm -rf /usr/local/lib/node_modules/npm
brew reinstall node
回答by tacticalmovephase
I followed the previous answers and reinstalled node. But I got this error.
我按照以前的答案并重新安装了节点。但我收到了这个错误。
Warning: The post-install step did not complete successfully You can try again using
brew postinstall node
警告:安装后步骤未成功完成您可以再次尝试使用
brew postinstall node
So I ran this command
所以我运行了这个命令
sudo chown -R $(whoami):admin /usr/local/lib/node_modules/
Then ran
然后跑了
brew postinstall node
回答by Denae
I received a similar error and now have it working.
我收到了类似的错误,现在可以正常工作了。
First make sure you have the latest version
首先确保你有最新版本
brew update
Remove your previous instance of node:
删除之前的节点实例:
brew uninstall node
Then reinstall the latest version:
然后重新安装最新版本:
brew install node
And then make sure it is symlinked into /usr/local if it isn't already. You would get an error to let you know to complete this step.
然后确保它已被符号链接到 /usr/local(如果还没有)。您会收到错误消息,通知您完成此步骤。
brew link --overwrite node
More details on how to install/upgrade node are also available.
还提供了有关如何安装/升级节点的更多详细信息。
回答by George Stocker
On Mac OS X (10.12.6), I resolved this issue by doing the following:
在 Mac OS X (10.12.6) 上,我通过执行以下操作解决了这个问题:
brew uninstall --force node
brew install node
I then got an error complaining that node postinstall failed, and to rerun brew postinstall node
然后我收到一个错误,抱怨 node postinstall 失败,并重新运行 brew postinstall node
I then got an error:
然后我得到一个错误:
permission denied @ rb_sysopen /usr/local/lib/node_modules/npm/bin/npx
I resolved that error by:
我通过以下方式解决了该错误:
sudo chown -R $(whoami):admin /usr/local/lib/node_modules
And now I don't get this error any more.
现在我不再收到这个错误了。
回答by phil
If you are using "n" library @ https://github.com/tj/n. Do the following
如果您使用“n”库@ https://github.com/tj/n。请执行下列操作
echo $NODE_PATH
If node path is empty, then
如果节点路径为空,则
sudo n latest - sudo is optional depending on your system
After switching Node.js versions using n, npm may not work properly.
使用 n 切换 Node.js 版本后,npm 可能无法正常工作。
curl -0 -L https://npmjs.com/install.sh | sudo sh
echo NODE_PATH
You should see your Node Path now. Else, it might be something else
您现在应该会看到您的节点路径。否则,它可能是别的东西
回答by Hymanotonye
As mentioned earlier.
如前面提到的。
sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node
brew install node
回答by Jerry Chong
Tried all above/older brew installation answers, none is working for my laptop.
尝试了以上所有/较旧的 brew 安装答案,没有一个适用于我的笔记本电脑。
Only below method could fix my issue.
只有以下方法可以解决我的问题。
1) Run following commands:
1)运行以下命令:
sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node
2) Then, proceed to Node.js Official Website https://nodejs.org/en/download/current/to download latest package for new installation.
2) 然后,前往 Node.js 官网https://nodejs.org/en/download/current/下载最新安装包。
3) Run your npm command again, which should longer have any errors.
3)再次运行你的 npm 命令,它应该不再有任何错误。
This method is working on macOS Mojave Version 10.14.4.
此方法适用于macOS Mojave 版本 10.14.4。
回答by C Williams
Simply download node from the official website, this worked for me! :)
只需从官方网站下载节点,这对我有用!:)
回答by Laxmikanta Nayak
Simply follow three steps;
只需遵循三个步骤;
Clear
npmcache forcefully:npm cache clean -fInstall
npackage globally usingnpm:npm install -g nInstall from any of three options:
a.
sudo n stable (get the stable version)b.
sudo n latest (get the latest version of node)c.
sudo n x.x.x (get the specific version of node)
npm强制清除缓存:npm cache clean -fn使用npm以下命令全局安装软件包:npm install -g n从三个选项中的任何一个安装:
一种。
sudo n stable (get the stable version)湾
sudo n latest (get the latest version of node)C。
sudo n x.x.x (get the specific version of node)
回答by Walterwhites
Yes you should re-install node:
是的,您应该重新安装节点:
sudo rm -rf /usr/local/lib/node_modules/npm
brew uninstall --force node
brew install node

