Node.js is a JavaScript runtime that allows you to run JavaScript on the server-side. NPM (Node Package Manager) is a package manager for Node.js that allows you to easily install and manage dependencies and packages for your Node.js projects. In this tutorial, we will guide you through the process of installing Node.js and NPM on a Mac.
Step 1: Install Homebrew
Homebrew is a package manager for macOS that allows you to easily install and manage software packages. To install Homebrew, open Terminal and paste the following command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Follow the on-screen instructions to complete the installation.
Step 2: Install Node.js and NPM
Once Homebrew is installed, you can use it to install Node.js and NPM. In Terminal, run the following command:
brew install node
This will download and install Node.js and NPM on your Mac.
Step 3: Verify Installation
To verify that Node.js and NPM have been installed correctly, you can run the following commands in Terminal:
node -v
npm -v
These commands will output the versions of Node.js and NPM that are installed on your Mac.
Step 4: Update NPM (Optional)
If you want to update NPM to the latest version, you can run the following command in Terminal:
npm install -g npm
This will update NPM to the latest version.
Step 5: Creating a Node.js Project
Now that Node.js and NPM are installed on your Mac, you can start creating Node.js projects. To create a new Node.js project, create a new directory for your project and navigate to it in Terminal. Then, run the following command to initialize a new Node.js project:
npm init
Follow the on-screen instructions to create a new package.json file for your project.
Step 6: Installing Packages
You can use NPM to install packages and dependencies for your Node.js project. To install a package, run the following command in Terminal:
npm install <package-name>
Replace <package-name>
with the name of the package you want to install.
Step 7: Running Your Node.js Project
To run your Node.js project, navigate to the project directory in Terminal and run the following command:
node <filename>.js
Replace <filename>
with the name of the JavaScript file that contains your Node.js code.
That’s it! You have successfully installed Node.js and NPM on your Mac and created a new Node.js project. You are now ready to start building and running Node.js applications on your Mac.
Where is NPM?
Straight to the point, did what I wanted.
Nowadays my first resolution when a problem pops up is chatgpt. It was giving me all sorts of confusing advice like
run nano ~/.zshrc
and then add export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
which im sure is a solution that works? But I was sitting here thinking "this can not be that difficult to pull off" lol
Turns out, I was right. Thanks
Thank you
thanks
How to installation my SQL on vs code editor in windows. Video upload please.