I always get this error message when I run \"Ionic start project name\":
Running command - failed![ERROR] An error occurred while run
The error Cannot find module '../lib/utils/unsupported.js'
is caused by require('../lib/utils/unsupported.js')
in ./lib/node_modules/npm/bin/npm-cli.js
.
According to the nodejs require docs, the required module is searched relative to the file, as it starts with ../
.
Thus, if we take the relative path ../lib/utils/unsupported.js
starting from ./lib/node_modules/npm/bin/npm-cli.js
, the required module must reside in ./lib/node_modules/npm/lib/utils/unsupported.js
. If it is not there, I see two options:
npm
is no symlink to ./lib/node_modules/npm/bin/npm-cli.js
. This is what caused the error in my setup. If you call npm
, it will typically find it be searching it in the directories listed in the PATH
env var. It might for example be located in ./bin
. However, npm
in a ./bin
directory should only be a symlink to the aforementioned ./lib/node_modules/npm/bin/npm-cli.js
. If it is not a symlink but directly contains the code, somewhere in the installation process the symlink got replaced by the file it links to. In this case, it should be sufficient to recreate the symlink: cd ./bin; rm npm; ln -s ../lib/node_modules/npm/bin/npm-cli.js npm
(update: command fixed, thx @massimo)All answers that suggest to check the NODE_PATH
or the npmrc
config should be ignored, as these are not considered when searching modules relatively.
I got this error by mixing install/update methods: installed node via downloading package from website and later I used brew to update.
I fixed by uninstalling the brew version :
brew uninstall --ignore-dependencies node
Then I went back to node website and downloaded and installed via the package manager: https://nodejs.org/en/download/ For some reason, no amount of trying to reinstall via brew worked.
Tried all above/older brew installation answers, none is working for my laptop.
Only below method could fix my issue.
1) Run following commands:
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.
3) Run your npm command again, which should longer have any errors.
This method is working on macOS Mojave Version 10.14.4.
https://nodejs.org/en/
Simply download node from the official website, this worked for me! :)
Simply follow three steps;
Clear npm
cache forcefully:
npm cache clean -f
Install n
package globally using npm
:
npm install -g n
Install 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)
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
So I ran this command
sudo chown -R $(whoami):admin /usr/local/lib/node_modules/
Then ran
brew postinstall node