1

I just tried to install node and npm on Debian Stretch. I installed node like decribed here.

After installing nodejs-legacy too I got the node command working but npm command still won't be found.

So, I tried to install it manually via apt-get install npm but it just tells me that it can't find the package. Next I tried the "Fancy Install (Unix)" from npm repository which fails with

    install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-5.5.1.tgz
module.js:327
    throw err;
    ^

Error: Cannot find module '/tmp/npm.1272/package/bin/read-package-json.js'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Function.Module.runMain (module.js:441:10)
    at startup (node.js:140:18)
    at node.js:1043:3
added 1 package and removed 1 package in 0.45s
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
+ npm@5.5.1
updated 1 package in 1.21s
It worked

Although it creates the link for the npm command the links are broken. Does anyone an idea how I can get npm running?

One more thing: I have the visual studio code repositories in my sources.list which uses node too. Is it possible that that's a reason why it downloads a node package without npm when I do apt-get install -y nodejs?

Thanks in advance for every answer.

| improve this question | | | | |
  • You could try downloading and compiling the source manually: nodejs.org/dist/latest I know that NPM is included in those packages from at least v6 and later. Additionally, I am using NVM on osx to manage versions but it also has install capability...maybe you could try installing via nvm and seeing if that fixes your issue. github.com/creationix/nvm – jesse_b Nov 11 '17 at 23:08
2

It seems as if it should be available in the npm package but there's a problem:

Error: Package not available in this suite

I read somewhere that it's deliberately not available because there are so many outstanding security issues (with the packaged version). I solved my problem without any "sudo run this script from the Internet" solutions like this:

cd /tmp/
wget  https://deb.nodesource.com/setup_8.x
view  setup_8.x
echo 'deb https://deb.nodesource.com/node_8.x  stretch  main' > /etc/apt/sources.list.d/nodesource.list
wget -qO - https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
apt update
apt install  nodejs

npm is installed as part of that nodejs package.

| improve this answer | | | | |
  • Yes that was a part of my problem, any idea how to circumvent that without nvm (which worked for me)? – J. Dietz Jun 1 '18 at 19:33
1

I have no idea why my tries from above did not work but for me installing nvm like described here and then performing nvm install node worked perfectly.

| improve this answer | | | | |
0

I solved the error about the missing read-package-json.js by using the latest install script from https://raw.githubusercontent.com/npm/npm/latest/scripts/install.sh. (Source: https://github.com/npm/npm/issues/18524#issuecomment-385369514).

After that you might run into an error about missing rimraf. At least for this there is a Debian Stretch package: apt install node-rimraf. For alternatives, see https://github.com/npm/npm/issues/18524 and https://github.com/npm/npm/issues/19105.

Finally, you might run into an error about missing make if you don't have that installed yet, so apt install make.

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.