Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Updating NPM with Nodist

I'm unable to update npm, and get it to use with Nodist.

Whenever I try to update npm with the command

npm install -g npm

the following message comes right after executing it:

(node:5304) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.

C:\Program Files (x86)\Nodist\v\nodev6.5.0\npm -> C:\Program Files (x86)\Nodist\v\nodev6.5.0\node_modules\npm\bin\npm-cli.js

[email protected] C:\Program Files (x86)\Nodist\v\nodev6.5.0\node_modules\npm

Doing an npm -v right after, gives me the previous version:

...> npm -v
2.14.10

However, if you noticed the last line in the message above, there is [email protected] which means it is somehow trying to install that version of npm.

I also followed instructions from this post for Ubuntu users and this for Windows users, but they seem to address issues with standalone NodeJS installations and NOT NodeJS + Nodist combo.

Meanwhile, I was wondering if Nodist itself enables us to update npm, or in other words, does it have any version management feature for npm as well, just as it does for node.

Thanks for any help in advance.


Additional Info

I am using Nodist v0.7.1 on Windows 7.

like image 435
Ahmad Baktash Hayeri Avatar asked Feb 07 '23 05:02

Ahmad Baktash Hayeri


2 Answers

You can try nodist npm latest

Nodist manages npm versions as well as node versions.

like image 162
John Avatar answered Feb 09 '23 00:02

John


Turns out that Nodist versions prior to v0.7.2 have an issue with getting npm set with Nodist correctly (refer the Nodist changelog).

Performing an npm install -g npm was in fact installing the latest version of npm under the v-x64 in Nodist's root installation folder - which is not where Nodist itself looks for npm installation.

Nodist looks for npm inside the \bin folder:

enter image description here

Solution

  1. Add the bin folder's path to your PATH.
  2. cd to the Nodist installation > bin directory with your terminal, and then perform:

     npm install npm 
    

    (not with -g flag of course).

    Alternatively, if npm install doesn't work in this step, copy an already installed npm and paste it in the node_modules folder within the bin directory.


As a side note, remember to remove some values from your PATH which I suppose may cause conflicts with global package installations (i.e. with -g flag) with npm, before installing Nodist, which are as follows:

  • %appdata%\npm; OR C:\Users\username\AppData\Roaming\npm;
  • %ProgramFiles%\nodejs;
like image 40
Ahmad Baktash Hayeri Avatar answered Feb 08 '23 23:02

Ahmad Baktash Hayeri