Using
homebrewinstallnvm:brew update brew install nvm source $(brew --prefix nvm)/nvm.shAdd the last command to the
.profile,.bashrcor.zshrcfile to not run it again on every terminal start. So for example to add it to the.profilerun:echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.profileIf you have trouble with installing
nvmusingbrewyou can install it manually (see here)Using
nvminstallnodeoriojs(you can install any version you want):nvm install 0.10 # or nvm install iojs-1.2.0npmis shipping withnode(oriojs), so it will be available after installingnode(oriojs). You may want to upgrade it to the latest version:$ npm install -g npm@latestUPD Previous version was
. Thanks to @Metallica for pointing to the correct way (see the comment below).npm update -g npmUsing
npminstallionic:npm install -g ionicWhat about
ngCordova: you can install it usingnpmorbower. I don't know what variant is more fit for you, it depends on the package manager you want to use for the client side. So I'll describe them both:Using
npm: Go to your project folder and installng-cordovain it:npm install --save ng-cordovaUsing
bower: Install bower:npm install -g bowerAnd then go to your project folder and install
ngCordovain it:bower install --save ngCordova
PS
- Some commands may require superuser privilege
- Short variant of
npm install some_moduleisnpm i some_module
Using
homebrewinstallnvm:brew update brew install nvm source $(brew --prefix nvm)/nvm.shAdd the last command to the
.profile,.bashrcor.zshrcfile to not run it again on every terminal start. So for example to add it to the.profilerun:echo "source $(brew --prefix nvm)/nvm.sh" >> ~/.profileIf you have trouble with installing
nvmusingbrewyou can install it manually (see here)Using
nvminstallnodeoriojs(you can install any version you want):nvm install 0.10 # or nvm install iojs-1.2.0npmis shipping withnode(oriojs), so it will be available after installingnode(oriojs). You may want to upgrade it to the latest version:$ npm install -g npm@latestUPD Previous version was
. Thanks to @Metallica for pointing to the correct way (see the comment below).npm update -g npmUsing
npminstallionic:npm install -g ionicWhat about
ngCordova: you can install it usingnpmorbower. I don't know what variant is more fit for you, it depends on the package manager you want to use for the client side. So I'll describe them both:Using
npm: Go to your project folder and installng-cordovain it:npm install --save ng-cordovaUsing
bower: Install bower:npm install -g bowerAnd then go to your project folder and install
ngCordovain it:bower install --save ngCordova
PS
- Some commands may require superuser privilege
- Short variant of
npm install some_moduleisnpm i some_module
Use nvm to install Node.js, not Homebrew
In most of the answers, the recommended way to install nvm is to use Homebrew.
Don't do this.
On nvm's Github Readme is clearly says:
Homebrew installation is not supported. If you have issues with homebrew-installed
nvm, pleasebrew uninstallit, and install it using the instructions below, before filing an issue.
Use the following method instead
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
And then use nvm to install node. For example to install latest LTS version do:
nvm install 16
Clean and hassle free. It will set this as your default Node.js version as well so you should be all set.
Videos
I come across this decision every time I get a new Mac laptop/computer.
I like nvm, node version manager, because it allows me to install multiple versions of node/npm in case I need to switch within different versions.
Does homebrew offer the same? Are there other install recommendations for Mac?
The need to switch node versions does come up when asked to work on another project that is “stuck” on an older version of node due to outdated packages that no one wants to maintain but is still used in the project.
April 12, 2023 Update Thanks for all the great recommendations and insight. I decided to use fnm for my own preference at this time, but all alternatives seem great in their own way. Here is a great article from Honeybadger comparing many node environment managers: https://www.honeybadger.io/blog/node-environment-managers
I installed node in the past with the help of someone irrc, but npm is not installed when I checked:
Mac-Users-Apple-Computer:~ z$ npm -v
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
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:153:3)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)I guess I wanted to try a clean install of node.js with npm, but when I tried to remove node, I got this, a yarn dependency, something I also had someone help install at some point for something(can tell, I'm a newbie to this):
Mac-Users-Apple-Computer:~ z$ brew uninstall node Error: Refusing to uninstall /usr/local/Cellar/node/11.11.0 because it is required by yarn, which is currently installed. You can override this and force removal with: brew uninstall --ignore-dependencies node
Should I override / remove node and do an install from scratch? Or can I install npm separately(don't know that that would be advised). it seems brew install node should install node and npm based on a reference link further down below, I just don't see npm on my system right now and don't recall how i had node installed the first time.
here are some references I was looking at:
https://treehouse.github.io/installation-guides/mac/node-mac.html
https://stackoverflow.com/questions/11177954/how-do-i-completely-uninstall-node-js-and-reinstall-from-beginning-mac-os-x
Hi everyone,
I'm building a website where I would like to apply this effect. So I read that I need to install npm in order to download its dependencies. The thing is that when I execute the command npm install I get this error: -bash: npm: command not found I searched for this error trying to figuring out what's wrong but I could't find a solution. I'm currently using Mac High Sierra operating system.
Can you help me understand how to install npm correctly?
thanks