-4

I am trying to install node modules using the command npm i in Ubuntu, but This error I have

enter image description here

Then i tried this but it is also not working

sudo npm install -g n

Looking forward for the quick solution ... Thanks in advance

saima ali
  • 133
  • 9
  • Use `nvm` rather than installing node from executable – devpolo Jul 26 '23 at 20:50
  • The solution is explained in the second sentence of the screenshot! – Quentin Jul 26 '23 at 20:59
  • i am not getting what to do with that – saima ali Jul 26 '23 at 21:04
  • For other posts: Please review *[Why not upload images of code/errors when asking a question?](https://meta.stackoverflow.com/questions/285551/)* (e.g., *"Images should only be used to illustrate problems that* ***can't be made clear in any other way,*** *such as to provide screenshots of a user interface."*). – Peter Mortensen Sep 01 '23 at 13:54
  • This was used [as an example](https://meta.stackoverflow.com/questions/426241/apache-age-of-despair#comment970985_426251) on meta. A similar [kind of question](https://stackoverflow.com/questions/76679360) (15 answers). – Peter Mortensen Sep 01 '23 at 13:57
  • And [another one](https://stackoverflow.com/questions/76179839/facing-issues-while-installing-apache-age-on-windows). The approximately same number of answers, 13, is probably not a coincidence. – Peter Mortensen Sep 02 '23 at 10:36

10 Answers10

2

The solution is mentioned in the picture you attached in your question. You can use nvm to update to a specific version of node. If you haven't already set up nvm, do so by running:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash 

Load these changes by running:

source ~/.profile 

Check nvm is correctly installed by running: nvm --version.

Now, you can install the latest or specific version of Node using nvm.

nvm install node      // Installs latest Node version
nvm install 14.17.0   // Installs version 14.17, change the version to what you want to install. 

If you have multiple versions of node installed, you can select and use a particular one by running:

nvm use 14.17.0    // replace version to what you want to use. 

Reference: Link

Safi50
  • 379
  • 1
  • 7
  • Thanks i tried it but in my case it was even not recognizing nvm.. and giving me the suggestions .... – saima ali Jul 27 '23 at 05:43
  • @saimaali it was probably not recognizing nvm because the changes you installed weren't being reflected on the current instance of the VS Code terminal. If you save your changes using `source ~/.profile` and open up a new terminal, It would work! – Safi50 Jul 28 '23 at 09:40
2

You just need to update your Nodejs and NPM.

to update your NPM you need to run the following commands:

npm install -g npm

and to install the latest version of node

nvm install node

you can also list all the versions in your system running:

nvm ls

to choose another one version use:

nvm use 
Marcos Silva
  • 115
  • 5
1

This seems to be the problem with the version of npm package manager or NodeJS on your system.

First, try to update them to the latest stable release by running the following command:

npm install -g npm@latest

If running this install command still causes an error, which is highly unlikely.

You can use NVM

Saif Ali
  • 53
  • 3
0

I am posting the answer myself because after a lot struggle I get it fix so it may helpful for any other person.

I as using vs terminal to install node modules so I run the command and then solutions but they were not working Then I closed the VS Code and run the commad in ubunutu terminal

npm install -g npm@latest

Then I again opened the VS and run the command in vs terminal npm install, it worked..

#Apache-Age #postgresql

saima ali
  • 133
  • 9
0

Use nvm. I encountered similar challenges using npm while setting up AGE Viewer. Installing the latest version of nvm updates node.

Tito
  • 289
  • 8
0

remove any previous installation of node

now try installing nvm (Node version Manager)

install curl using the following command (if not already installed):

sudo apt-get install curl

now install nvm using the following command:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

then

source ~/.bashrc

check the nvm installation

nvm --version

now to install any version of of node JS

for example v14.17.0

nvm install 14.17.0

and to use it execute the following command:

nvm use 14.17.0

to install latest long term stable version

'nvm install --lts

0

I have struggled with this error myself and all you have to do is use the node version manager and after installing nvm you have to restart the terminal to get the problem fixed.

  • Whoever flagged this: this does not qualify is "Not an Answer." Please use a custom flag for any issues related to duplicating other answers. – General Grievance Sep 01 '23 at 15:17
0

While this error could be solved using multiple approaches as suggested above but the best way to solve it would be using nvm. Install Node Version Manager and then upgrade to the latest stable node version. You will have to install the latest node version first using nvm and then use the command nvm use {version} where version is the version you want to switch too. If it still does not work you can also try downgrading the node version.

0

Try the

npm install -g npm@latest

and then close the terminal, reboot and open again and install

npm i

it will help as in my case it worked..

samreena
  • 34
  • 2
0

The issue is with the node version manager. You need to install the latest version of node. For that, use this command:

nvm install node
adil shahid
  • 125
  • 4