elm-lang / elm-platform

Bundle of all core development tools for Elm
BSD 3-Clause "New" or "Revised" License
762 stars 125 forks source link

Permission denied in for npm install on ubuntu 16.10 #195

Closed kasrasadeghi closed 6 years ago

kasrasadeghi commented 7 years ago

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

process-bot commented 7 years ago

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.

kasrasadeghi commented 7 years ago

This is the log file. npm-debug.log

spikefoo commented 7 years ago

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?

kasrasadeghi commented 7 years ago

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.

kasrasadeghi commented 7 years ago

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

kasrasadeghi commented 7 years ago

I resolved it by following this thanks to @eeue56.

0xmichalis commented 7 years ago

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

benjamin-rood commented 7 years ago

@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.

minhchuduc commented 7 years ago

@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!

benjamin-rood commented 7 years ago

Never ever sudo chown anything like this. It can break your OS. Node is shit, stop using it. Try yarn instead. 

On Tue, 08 Aug 2017 at 2:19 PM minhchuduc

< mailto:minhchuduc notifications@github.com

wrote:

a, pre, code, a:link, body { word-wrap: break-word !important; }

https://github.com/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!

You are receiving this because you commented.

Reply to this email directly, https://github.com/elm-lang/elm-platform/issues/195#issuecomment-320831328 , or https://github.com/notifications/unsubscribe-auth/AJoldKg15a1bHavPBneAbyKW2DYDSng_ks5sV8W9gaJpZM4LehWk .

rtfeldman commented 6 years ago

OP's issue was resolved.