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:

Answer from James Lawruk on Stack Overflow
🌐
Reddit
reddit.com › r/node › help with node
r/node on Reddit: Help with Node
March 9, 2024 -

I want to preface this by saying I have absolutely no idea what I'm doing so I'm sorry if I say something stupid. I'm trying to download something from Github which says I need to install NodeJS and Yarn. I cloned the repository on Githuh, and it now says to run yarn on the root folder. I tried to install Yarn and it says I need to enable Corepack, but when I type 'corepack enable' into Node it says "Uncaught SyntaxError: Unidentified identifier 'enable'" Can someone give me a dumbed down guide on how to install Yarn through Node and how to run it on a root folder (I don't even know what that is) Again sorry for the stupidity

🌐
GitHub
github.com › dimotsai › agar-mini-map › issues › 44
npm should be run outside of the node repl, in your normal shell. · Issue #44 · dimotsai/agar-mini-map
September 10, 2015 - npm should be run outside of the node repl, in your normal shell.#44 · Copy link · Lysander405 · opened · on Sep 10, 2015 · Issue body actions · when I press cd agar-mini-map-v0.46-win-x64 it says: at Object.exports.createScript (vm.js:24:10) ...
Published   Sep 10, 2015
🌐
GitHub
github.com › npm › cli › issues › 4164
[BUG] Please respect the calling runtime and PATH. · Issue #4164 · npm/cli
August 6, 2021 - node Welcome to Node.js v17.1.0. Type ".help" for more information. > npm install -g node@latest npm should be run outside of the Node.js REPL, in your normal shell.
Published   Dec 11, 2021
🌐
YouTube
youtube.com › vlogize
Troubleshooting: Resolving 'npm should be run outside of the node repl, in your normal shell' in Nod - YouTube
Disclaimer/Disclosure: Some of the content was synthetically produced using various Generative AI (artificial intelligence) tools; so, there may be inaccurac...
Published   April 10, 2024
Views   267
🌐
GitHub
github.com › nodejs › node › issues › 54830
REPL doesn't handle `npm` correctly · Issue #54830 · nodejs/node
May 22, 2024 - > let npm = 1 > npm + npm should be run outside of the Node.js REPL, in your normal shell.
Published   Sep 07, 2024
🌐
Particle
community.particle.io › troubleshooting
[SOLVED]Need help getting started. I'm stuck with the node.js part - Troubleshooting - Particle
June 17, 2016 - I got the program to work with the phone app. Now I moved on to connected to the computer. I installed node.js. I typed in: npm install -g particle-cli and hit enter and is says this: npm should be run outside of the n…
🌐
YouTube
youtube.com › hey delphi
NodeJS : How to resolve 'npm should be run outside of the node repl, in your normal shell' - YouTube
NodeJS : How to resolve 'npm should be run outside of the node repl, in your normal shell'To Access My Live Chat Page, On Google, Search for "hows tech devel...
Published   April 20, 2023
Views   1K
Find elsewhere
🌐
Hubwiz
corpus.hubwiz.com › 2 › node.js › 24476805.html
How to resolve 'npm should be run outside of the node repl, in your normal shell'
For Windows users, run npm commands from the Command Prompt (cmd.exe), not Node.Js (node.exe). So your "normal shell" is cmd.exe.
🌐
Alibaba Cloud
topic.alibabacloud.com › tc › a › npm-should-be-run-outside-of-the-node-repl-in-your-normal-shell_1_28_30203934.html
npm should be run outside of the node repl, in your normal shell
npm ERR! Please include the following file with any support request: npm ERR! D:\Program Files\nodejs\npm-debug.log · 也就是說,想要運行node命令,需要在系統的shell中,比如windows的cmd。node內建的那個叫repl,不能在其中運行npm命令,只能運行js語句
🌐
Codyswartz
codyswartz.us › wp › finds › node-js-stand-alone-portable-with-npm
Node js Stand Alone Portable with NPM - Cody Swartz - Programmer · Web Developer · Gamer
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 to run commands (shift right-click “Open command window here”)
Top answer
1 of 1
30

Update

Regarding William Entriken's comment below this answer, there is a better way of installing Node.js natively in Ubuntu as a snap package.

Node.js is available as a snap package in all currently supported versions of Ubuntu. Specific to Node.js, developers can choose from one or more of the currently supported releases and get regular automatic updates directly from NodeSource. Node.js versions 6, 8, 9, 10, 11, 13, 14, 15, 16, 17 and 18 are currently available, with the Snap Store being updated within hours or minutes of a Node.js release.

Node can be installed with a single command, for example:

sudo snap install node --classic --channel 9/stable 

The node snap can be accessed by the command node, for example:

$ node -v  
v9.9.0

An up-to-date version of npm will installed as part of the node snap. npm should be run outside of the node repl, in your normal shell. After installing the node snap run the following command to enable npm update checking:

sudo chown -R $USER:$(id -gn $USER) /home/your-username/.config

Replace your-username in the above command with your own username. Then run npm -v to check if the version of npm is up-to-date. As an example I checked that npm was up-to-date, checked the version of an already installed package named yarn with the command npm list yarn and then updated the existing yarn package to the latest version with the command npm update yarn

Users can switch between versions of Node.js at any time without needing to involve additional tools like nvm (Node Version Manager), for example:

sudo snap refresh node --channel=8/stable

Users can test bleeding-edge versions of Node.js that can be installed from the latest edge channel by switching with:

sudo snap switch node --edge

This approach is only recommended for those users who are willing to participate in testing and bug reporting upstream.


Original answer

To install the latest LTS versions of Node.js (nodejs) and Package manager for Node.js (npm) in all currently supported versions of Ubuntu, open the terminal and run the following commands:

sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages
sudo apt-get install curl  
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs  

If you are copying these three commands, don't neglect the hyphen at the end of the second command.

The nodejs package contains the nodejs binary as well as npm, so you don't need to install npm separately. However, in order for some npm packages to work (such as those that require building from source), you will need to install the build-essential package:

sudo apt-get install build-essential  

LTS Plan

New semver-major releases of Node.js are cut from master every six months. New even-numbered versions (e.g. v6, v8, v10, etc.) are cut in April. New odd-numbered versions (e.g. v5, v7, v9) are cut in October.

When a new odd-numbered major release is cut, the previous even-numbered major version transitions to the Long Term Support plan.

Every major version covered by the LTS plan will be actively maintained for a period of 18 months from the date it enters LTS coverage. Following those 18 months of active support, the major version will transition into "maintenance" mode for 12 additional months.

non-LTS installation

Current to March, 2017 the commands to install the latest non-LTS version of Node.js (v8 at the time this was posted) are as follows:

sudo apt-get remove nodejs npm ## remove existing nodejs and npm packages
sudo apt-get install curl  
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs  

Node.js LTS schedule

Release Status Codename Initial release LTS Start Maintenance Start Maintenance End
6.x EOL Boron 2016-04-26 2016-10-18 2018-04-30 2019-04-30
7.x EOL 2017-05-30 2017-06-30
8.x EOL Carbon 2016-10-25 2017-10-31 2019-01-01 2019-12-31
9.x EOL 2017-10-01 2018-06-30
10.x EOL Dubnium 2018-04-24 2018-10-30 2020-05-19 2021-04-30
11.x EOL 2018-10-23 2019-06-01
12.x Maintenance LTS Erbium 2019-04-23 2019-10-21 2020-11-301 2022-04-30
13.x EOL 2019-10-22 2020-06-01
14.x Maintenance LTS Fermium 2020-04-21 2020-10-27 2021-10-30 2023-04-30
16.x Active LTS Gallium 2021-04-20 2021-10-26 2022-10-18 2024-04-30
17.x Current 2021-10-19 2022-04-01 2022-06-01
18.x Current 2022-04-19 2022-10-25 2023-10-18 2025-04-30
🌐
CrazyGeeks
crazygeeks.org › questions › how-to-resolve-npm-should-be-run-outside-of-the-node-repl-in-your-normal-shell
How to resolve 'npm should be run outside of the node repl, in your normal shell' - CrazyGeeks
If you were instead looking for the Express project generator (command), you need to do npm install -g express-generator for Express 4. You can use node anywhere from your command prompt to execute scripts. For example if you have already written a separate script: node foo.js. Or you can open up the REPL (as you've already found out) by just selecting the node.js (start menu) shortcut or by just typing node in a command prompt.
🌐
Programmersought
programmersought.com › article › 1563215930
How to solve npm should be run outside of the node repl, in your normal shell - Programmer Sought
REPL command ctrl + c-Exit the current terminal. ctrl + c Press twice-to exit Node REPL. ctrl + d-Exit the Node REPL. Up/Down keys-view the input history commands tab key-list current commands .help-L... 1, execution in the root directorynpm init --yesgeneratepackage.jsondocument 2, configure the scripts command Summary: You can use it at this timenpm run reset:edc replacenode reset.js... ... Run `npm rebuild node-sass` to download the binding for your current environment.
🌐
Adoclib
adoclib.com › blog › how-to-resolve-npm-should-be-run-outside-of-the-node-repl-in-your-normal-shell.html
How To Resolve 'Npm Should Be Run Outside Of The Node Repl, In Your Normal Shell'
npm is written in Node.js, so you need to install Node.js in order to use npm. You can If the version you see does not match the latest version, run: npm install Make a new directory outside of your project. Switch to the Then go into the node-repl, and try using require( my-thing ) to bring ...