[node.js] How to resolve 'npm should be run outside of the node repl, in your normal shell'

I am new to node.js. I downloaded and install node.js installer from the official site. I have added this installer folder in PATH environment variable and I am able to run programs. But when I try to install some package using npm in node console it shows the error npm should be run outside of the node repl, in your normal shell. I also tried it on a separate console. But it shows command not found though I have added node in the environment variable.

enter image description here

enter image description here

This question is related to node.js npm

The answer is


It's simple. Press the Windows logo on your keyboard. Then, type node.js command prompt in the search bar and run it. screenshot: run npm outside node repl


enter image description here

Just open Node.js commmand promt as run as administrator


You must get directory right path of program(node.js in program files).

such as

enter image description here

and use "npm install -g phonegap"


Do not run the application using node.js icon.

Go to All Programmes->Node.js->Node.js command prompt.

Below is example screen shot.

enter image description here

enter image description here


For Windows users, run npm commands from the Command Prompt (cmd.exe), not Node.Js (node.exe). So your "normal shell" is cmd.exe. (I agree this message can be confusing for a Windows, Node newbie.)

By the way, the Node.js Command Prompt is actually just an easy shortcut to cmd.exe.

Below is an example screenshot for installing grunt from cmd.exe:

enter image description here


you just open command prompt, then enter in c:/>('cd../../') then npm install -g cordova enter image description here


If you're like me running in a restricted environment without administrative privileges, that means your only way to get node up and running is to grab the executable (node.exe) without using the installer. You also cannot change the path variable which makes it that much more challenging.

Here's what I did (for Windows)

  1. Throw node.exe into its own folder (Downloaded the node.exe stand-alone )
  2. Grab an NPM release zip off of github: https://github.com/npm/npm/releases
  3. Create a folder named: node_modules in the node.exe folder
  4. Extract the NPM zip into the node_modules folder
  5. Make sure the top most folder is named npm (remove any of the versioning on the npm folder name ie: npm-2.12.1 --> npm)
  6. Copy npm.cmd out of the npm/bin folder into the top most folder with node.exe
  7. Open a command prompt to the node.exe directory (shift right-click "Open command window here")
  8. Now you will be able to run your npm installers via: npm install -g express

Running the installers through npm will now auto install packages where they need to be located (node_modules and the root)

Don't forget you will not be able to set the path variable if you do not have proper permissions. So your best route is to open a command prompt in the node.exe directory (shift right-click "Open command window here")


As mscdex said NPM comes with the nodejs msi installed file. I happened to just install the node js installer (standalone). To separately add NPM I followed following step

  1. Download the latest zip file of NPM from here.
  2. Extract it in the same file as that of node js installer.
  3. If you have added the directory containing to node js installer to PATH env variable then now even npm should be a recognized command.

Examples related to node.js

Hide Signs that Meteor.js was Used Querying date field in MongoDB with Mongoose SyntaxError: Cannot use import statement outside a module Server Discovery And Monitoring engine is deprecated How to fix ReferenceError: primordials is not defined in node UnhandledPromiseRejectionWarning: This error originated either by throwing inside of an async function without a catch block dyld: Library not loaded: /usr/local/opt/icu4c/lib/libicui18n.62.dylib error running php after installing node with brew on Mac internal/modules/cjs/loader.js:582 throw err DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean`

Examples related to npm

What does 'x packages are looking for funding' mean when running `npm install`? error: This is probably not a problem with npm. There is likely additional logging output above Module not found: Error: Can't resolve 'core-js/es6' Browserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist` ERROR in The Angular Compiler requires TypeScript >=3.1.1 and <3.2.0 but 3.2.1 was found instead DeprecationWarning: Buffer() is deprecated due to security and usability issues when I move my script to another server Please run `npm cache clean` What exactly is the 'react-scripts start' command? On npm install: Unhandled rejection Error: EACCES: permission denied Difference between npx and npm?