Node.js is a powerful JavaScript runtime that allows developers to build scalable network applications. NPM (Node Package Manager) is bundled with Node.js and helps manage dependencies efficiently. This guide will walk you through installing and configuring Node.js and NPM on a Windows machine.
Once installed, verify that Node.js and NPM are properly set up:
node -v
npm -v
If installed correctly, these commands will display the installed versions of Node.js and NPM.
To avoid permission errors when installing global packages, you can change the default directory:
mkdir "%USERPROFILE%\npm-global"
npm config set prefix "%USERPROFILE%\npm-global"
PATH
:Path
variable under User variables.%USERPROFILE%\npm-global\bin
Yarn is an alternative package manager that can be installed using NPM:
npm install -g yarn
Verify the installation:
yarn -v
To ensure everything is working, create a test file:
app.js
:console.log("Hello, Node.js!");
node app.js
You should see Hello, Node.js!
printed in the terminal.
You have successfully installed and configured Node.js and NPM on Windows. You are now ready to start building JavaScript applications and managing dependencies efficiently!