0

Initially I installed node using the command sudo apt install nodejs. This command installed an older version of node and npm so I removed the package using the command
sudo apt-get remove --purge nodejs.

To get the latest LTS version of nodejs I download the zip file extracted it to the path /usr/local/lib/nodejs/.

After this to set the environment variable of nodejs I took the path of nodejs bin file, then configured the path to .bashrc file which was present in the home directory.

This is how I installed the latest LTS version of nodejs and npm. I also verified the installation by checking the versions of node and npm in my system.

Now when I run npm install -g nodemon it gives me error stating that you need specific permissions to do so.

Then I tried sudo npm install -g nodemon, now it says command not found.

But I can install nodemon locally (i.e npm install nodemon works fine but still can't start the node server using nodemon). What I want is to install nodemon globally and use it to start my server

I googled around and tried several things but it didn't really work for me.

Newbie here... It's been two weeks where I have totally wiped windows from my system and installed ubuntu in it.

5
  • I tried this command it says "sudo: npm: command not found" Feb 23, 2023 at 19:25
  • Initially I installed node using the command sudo apt install nodejs. This command installed an older version of node and npm so I removed the package using the command sudo apt-get remove --purge nodejs. To get the latest LTS version of nodejs i download the zip file extracted it to the path /usr/local/lib/nodejs/ After this to set the environment variable of nodejs I took the path of nodejs bin file, then configured the path to .bashrc file which was present in the home directory. This is how I installed the latest LTS version of nodejs and npm. Thank you Feb 25, 2023 at 8:05
  • Thank you, I have edited my post. Feb 25, 2023 at 8:36
  • 2
    Does this answer your question? How to install the latest versions of NodeJS and NPM?
    – user68186
    Feb 25, 2023 at 14:19
  • Your installation is the problem. See the answers in the above link and install using either the PPA (will take less disk space) or snap (takes more disks space but runs in a sandbox).
    – user68186
    Feb 25, 2023 at 15:10

1 Answer 1

0

Firstly, you can install npm on Ubuntu 22.04 LTS by opening terminal and run the following commands:

$ sudo apt update

$ sudo apt install npm

After that, you can install nodemon globally on our system with the following command:

$ sudo npm install -g nodemon

I tested and installed nodemon successfully on my Ubuntu 22.04.2 LTS server. Hope this help you fix your problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .