Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Permission denied error while attempting to install elm with sudo on ubuntu

I am attempting to install elm on my machine (Ubuntu 16.04.2 LTS).

Running $ npm install -g elm as per the instructions at that link, I get a permission error. So I try again with sudo, i.e. $ sudo npm install -g elm.

This gives another permission error, namely

$ sudo npm install -g elm
npm WARN deprecated [email protected]: Use uuid module instead
/usr/local/bin/elm-package -> /usr/local/lib/node_modules/elm/binwrappers/elm-package
/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-reactor -> /usr/local/lib/node_modules/elm/binwrappers/elm-reactor
/usr/local/bin/elm-repl -> /usr/local/lib/node_modules/elm/binwrappers/elm-repl

> [email protected] install /usr/local/lib/node_modules/elm
> node install.js

Error extracting linux-x64.tar.gz - Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/elm/Elm-Platform'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/matthew/.npm/_logs/2017-07-03T05_58_24_401Z-debug.log

The end of that referenced log file (at /home/matthew/.npm/_logs/2017-07-03T05_58_24_401Z-debug.log) is shown below.

...
2499 verbose linkBins [email protected]
2500 verbose linkMans [email protected]
2501 silly build [email protected]
2502 info linkStuff [email protected]
2503 silly linkStuff [email protected] has /usr/local/lib/node_modules/elm/node_modules as its parent node_modules
2504 silly linkStuff [email protected] is part of a global install
2505 silly linkStuff [email protected] is installed into a global node_modules
2506 verbose linkBins [email protected]
2507 verbose linkMans [email protected]
2508 silly build [email protected]
2509 info linkStuff [email protected]
2510 silly linkStuff [email protected] has /usr/local/lib/node_modules/elm/node_modules as its parent node_modules
2511 silly linkStuff [email protected] is part of a global install
2512 silly linkStuff [email protected] is installed into a global node_modules
2513 verbose linkBins [email protected]
2514 verbose linkMans [email protected]
2515 silly doSerial global-link 736
2516 silly doParallel update-linked 736
2517 silly doSerial install 736
2518 silly install [email protected]
2519 info lifecycle [email protected]~install: [email protected]
2520 verbose lifecycle [email protected]~install: unsafe-perm in lifecycle false
2521 verbose lifecycle [email protected]~install: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/usr/local/lib/node_modules/elm/node_modules/.bin:/usr/local/lib/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin
2522 verbose lifecycle [email protected]~install: CWD: /usr/local/lib/node_modules/elm
2523 silly lifecycle [email protected]~install: Args: [ '-c', 'node install.js' ]
2524 silly lifecycle [email protected]~install: Returned: code: 1  signal: null
2525 info lifecycle [email protected]~install: Failed to exec install script
2526 verbose unlock done using /home/matthew/.npm/_locks/staging-3a08f0df5026584d.lock for /usr/local/lib/node_modules/.staging
2527 verbose stack Error: [email protected] install: `node install.js`
2527 verbose stack Exit status 1
2527 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:283:16)
2527 verbose stack     at emitTwo (events.js:125:13)
2527 verbose stack     at EventEmitter.emit (events.js:213:7)
2527 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
2527 verbose stack     at emitTwo (events.js:125:13)
2527 verbose stack     at ChildProcess.emit (events.js:213:7)
2527 verbose stack     at maybeClose (internal/child_process.js:887:16)
2527 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:208:5)
2528 verbose pkgid [email protected]
2529 verbose cwd /home/matthew
2530 verbose Linux 4.8.0-56-generic
2531 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "elm"
2532 verbose node v8.0.0
2533 verbose npm  v5.0.4
2534 error code ELIFECYCLE
2535 error errno 1
2536 error [email protected] install: `node install.js`
2536 error Exit status 1
2537 error Failed at the [email protected] install script.
2537 error This is probably not a problem with npm. There is likely additional logging output above.
2538 verbose exit [ 1, true ]

How can I proceed to install Elm?

like image 353
mherzl Avatar asked Jul 03 '17 06:07

mherzl


1 Answers

Ideally, the permissions on /usr/local/lib/node_modules/ are such that you don't need root privileges to install something there.

If that's not possible, you need to tell npm that is should not drop its root privileges (which is a safe-guard to prevent rogue installation scripts from running as root):

$ sudo npm install --unsafe-perm -g elm
like image 57
robertklep Avatar answered Nov 03 '22 03:11

robertklep