尝试在ubuntu上安装带有sudo的elm时,权限被拒绝

时间:2017-07-03 06:11:53

标签: node.js ubuntu npm elm

我正在尝试在我的机器上安装elm(Ubuntu 16.04.2 LTS)。

根据该链接的说明运行$ npm install -g elm,我收到了权限错误。所以我再次尝试使用sudo,即$ sudo npm install -g elm

这会产生另一个权限错误,即

$ sudo npm install -g elm
npm WARN deprecated node-uuid@1.4.8: 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

> elm@0.18.0 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! elm@0.18.0 install: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the elm@0.18.0 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

该引用日志文件的结尾(在/home/matthew/.npm/_logs/2017-07-03T05_58_24_401Z-debug.log中)如下所示。

...
2499 verbose linkBins asap@2.0.5
2500 verbose linkMans asap@2.0.5
2501 silly build ansi-styles@2.2.1
2502 info linkStuff ansi-styles@2.2.1
2503 silly linkStuff ansi-styles@2.2.1 has /usr/local/lib/node_modules/elm/node_modules as its parent node_modules
2504 silly linkStuff ansi-styles@2.2.1 is part of a global install
2505 silly linkStuff ansi-styles@2.2.1 is installed into a global node_modules
2506 verbose linkBins ansi-styles@2.2.1
2507 verbose linkMans ansi-styles@2.2.1
2508 silly build ansi-regex@2.1.1
2509 info linkStuff ansi-regex@2.1.1
2510 silly linkStuff ansi-regex@2.1.1 has /usr/local/lib/node_modules/elm/node_modules as its parent node_modules
2511 silly linkStuff ansi-regex@2.1.1 is part of a global install
2512 silly linkStuff ansi-regex@2.1.1 is installed into a global node_modules
2513 verbose linkBins ansi-regex@2.1.1
2514 verbose linkMans ansi-regex@2.1.1
2515 silly doSerial global-link 736
2516 silly doParallel update-linked 736
2517 silly doSerial install 736
2518 silly install elm@0.18.0
2519 info lifecycle elm@0.18.0~install: elm@0.18.0
2520 verbose lifecycle elm@0.18.0~install: unsafe-perm in lifecycle false
2521 verbose lifecycle elm@0.18.0~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 elm@0.18.0~install: CWD: /usr/local/lib/node_modules/elm
2523 silly lifecycle elm@0.18.0~install: Args: [ '-c', 'node install.js' ]
2524 silly lifecycle elm@0.18.0~install: Returned: code: 1  signal: null
2525 info lifecycle elm@0.18.0~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: elm@0.18.0 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 elm@0.18.0
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 elm@0.18.0 install: `node install.js`
2536 error Exit status 1
2537 error Failed at the elm@0.18.0 install script.
2537 error This is probably not a problem with npm. There is likely additional logging output above.
2538 verbose exit [ 1, true ]

如何安装Elm?

1 个答案:

答案 0 :(得分:21)

理想情况下,/usr/local/lib/node_modules/上的权限使您无需root权限即可在其中安装。

如果这不可能,您需要告诉npm不应该删除其root权限(这是防止恶意安装脚本以root身份运行的安全措施):

$ sudo npm install --unsafe-perm -g elm
相关问题