How do I list Node.js version and path currently being used in npm?

12,321

I just tried npm info which isn't a thing evidently, because I got all errors. But the first line was my OS version, second was PATH to node.exe and PATH to npm-cli.js, third was node version, fourth was npm version. Then invalid package.json, etc, etc I'm sure there's a right way, but I think it showed me everything you are hoping to see... Forgive me for suggesting bad answer. Maybe just check your npm-debug.log Perhaps you can find answers to your questions there.

** EDIT I found something in npm help

try npm config list

Share:
12,321
Christopher Sheaf
Author by

Christopher Sheaf

Updated on June 04, 2022

Comments

  • Christopher Sheaf
    Christopher Sheaf almost 2 years

    I'm currently running into the same error as this Stackoverflow question had: SyntaxError: Use of const in strict mode?, although I'm getting it while trying to install Flux.

    I've already updated my system's Node.js version with the commands shown in the linked Stackoverflow question.

    npm cache clean -f
    sudo npm install -g n
    sudo n stable
    

    When I run node --version I get the correct version, v8.2.1. However, when I install modules via npm, I still get warnings such as

    npm WARN engine [email protected]: wanted: {"node":">=4"} (current: {"node":"v0.10.25","npm":"1.3.10"})
    

    ...which suggests that npm is still using an old version of Node.

    Is there a way that I can find the version of Node seen by npm, and can I determine the directory where it is installed to?

    • k0pernikus
      k0pernikus almost 7 years
      What does which npm print?
    • Julien
      Julien almost 7 years
      check that nodejs --version also returns the correct version
  • Christopher Sheaf
    Christopher Sheaf almost 7 years
    npm config list gave me the node bin location, and also led me to npm config ls -l which contained a node-version string. As it turns out, npm is using an absolute path to /usr/bin/nodejs. The latest version of node is installed to /usr/local/bin/node with a symlink to /usr/local/bin/nodejs, but npm seems happy to ignore my $PATH variable entirely. Now I just need to find a way to point npm to the proper directory and I'm set.