elm-lang / elm-platform

Bundle of all core development tools for Elm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Permission denied in for npm install on ubuntu 16.10

kasrasadeghi opened this issue · comments

I'm using nvm to install Node.js.

After doing so, when I try
npm install -g elm

it gives the following printout:

root@Ubuntu:~# npm install -g elmh
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
/home/username/.nvm/versions/node/v7.4.0/bin/elm-make -> /home/username
/.nvm/versions/node/v7.4.0/lib/node_modules/elm/binwrappers/elm-make
/home/username/.nvm/versions/node/v7.4.0/bin/elm -> /home/username/.nvm/versions/node/v7.4.0/lib/node_modules/elm/binwrappers/elm
/home/username/.nvm/versions/node/v7.4.0/bin/elm-package -> /home/username/.nvm/versions/node/v7.4.0/lib/node_modules/elm/binwrappers/elm-package
/home/username/.nvm/versions/node/v7.4.0/bin/elm-reactor -> /home/username/.nvm/versions/node/v7.4.0/lib/node_modules/elm/binwrappers/elm-reactor
/home/username/.nvm/versions/node/v7.4.0/bin/elm-repl -> /home/username/.nvm/versions/node/v7.4.0/lib/node_modules/elm/binwrappers/elm-repl

> elm@0.18.0 install /home/username/.nvm/versions/node/v7.4.0/lib/node_modules/elm
> node install.js

sh: 1: node: Permission denied
npm ERR! Linux 4.8.0-32-generic
npm ERR! argv "/home/username/.nvm/versions/node/v7.4.0/bin/node" "/home/username/.nvm/versions/node/v7.4.0/bin/npm" "install" "-g" "elm"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! elm@0.18.0 install: `node install.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the elm@0.18.0 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the elm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs elm
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls elm
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/username/npm-debug.log

EDIT:
This is on Ubuntu 16.10

Thanks for the issue! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

This is the log file.
npm-debug.log

Reproduced with a similar error using a fresh Ubuntu 16.04 (after installing nodejs and npm):

root@test:~# npm install -g elm
npm WARN deprecated node-uuid@1.4.7: use uuid module instead
/usr/local/bin/elm -> /usr/local/lib/node_modules/elm/binwrappers/elm
/usr/local/bin/elm-make -> /usr/local/lib/node_modules/elm/binwrappers/elm-make
/usr/local/bin/elm-package -> /usr/local/lib/node_modules/elm/binwrappers/elm-package
/usr/local/bin/elm-reactor -> /usr/local/lib/node_modules/elm/binwrappers/elm-reactor
/usr/local/bin/elm-repl -> /usr/local/lib/node_modules/elm/binwrappers/elm-repl

> elm@0.18.0 install /usr/local/lib/node_modules/elm
> node install.js

sh: 1: node: not found
npm ERR! Linux 4.4.0-57-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "elm"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn

npm ERR! elm@0.18.0 install: `node install.js`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the elm@0.18.0 install script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the elm package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs elm
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls elm
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /root/npm-debug.log

It was fixed for me after running apt-get install nodejs-legacy, which installs a symlink (/usr/bin/node -> nodejs). Does it work for you?

The error probably comes from this line:

"install": "node install.js"

Can it be fixed so it works for Ubuntu users who didn't install nodejs-legacy?
Or should the documentation for the NPM package be updated to say Ubuntu users must install nodejs-legacy?

Installing nodejs-legacy didn't work. I also tried just installing nodejs. As I'm using NVM, the executable for node.js is "node" and while your line says sh: 1: node: not found mine says sh: 1: node: Permission denied, even as root.

I think I may need to find the node executable and then chown something.
EDIT: nope, that doesn't seem to have worked.

I resolved it by following this thanks to @eeue56.

Stumbled upon the same issue on an Ubuntu 16.10 machine, installing nodejs-legacy did the trick.

@kasrasadeghi As a general rule/warning to everyone: NEVER CHOWN ANYTHING IN YOUR /usr or any default root directory. It can seriously ruin your OS.

@kasrasadeghi you can fix it by:

$ sudo chown -R $(whoami) ~/.npm
$ sudo chown -R $(whoami) /usr/local/lib/node_modules

then reinstall elm by:
$ npm install -g elm ## NO SUDO! NO ROOT!