How can I update NodeJS and NPM to the next versions?

后端 未结 30 1969
北荒
北荒 2020-11-22 08:07

I just installed Node.js and npm (for additional modules).

How can I update Node.js and the modules which I\'m using to the latest versions

30条回答
  •  孤独总比滥情好
    2020-11-22 08:51

    I just installed Node.js on a new Windows 7 machine, with the following results:

    > node -v
    v0.12.0
    > npm -v
    2.5.1
    

    I then did the above described procedure:

    > npm install -g npm
    

    and it upgraded to v2.7.3. Except than doing npm -v still gave 2.5.1.

    I went to the System configuration panel, advanced settings, environment variables. I saw a PATH variable specific to my user account, in addition to the global Path variable.
    The former pointed to new npm: C:\Users\PhiLho\AppData\Roaming\npm
    The latter includes the path to node: C:\PrgCmdLine\nodejs\ (Nowadays, I avoid to install stuff in Program Files and derivates. Avoiding spaces in paths, and noisy useless protections is saner...)
    If I do which npm.cmd (I have Unix utilities installed...), it points to the one in Node.

    Anyway, the fix is simple: I just copied the first path (to npm) just before the path to node in the main, global Path variable, and now it picks up the latest version.
    ;C:\Users\PhiLho\AppData\Roaming\npm;C:\PrgCmdLine\nodejs\

    > npm -v
    2.7.3
    

    Enjoy. :-)

提交回复
热议问题