问题通过npm在Arch Linux上安装Polymer

时间:2018-01-28 19:44:35

标签: npm polymer polymer-2.x

安装Polymer CLI时出现以下错误,如下所示

sudo npm install -g polymer-cli


29577 info lifecycle wd@1.5.0~install: wd@1.5.0
29578 verbose lifecycle wd@1.5.0~install: unsafe-perm in lifecycle false
29579 verbose lifecycle wd@1.5.0~install: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/usr/lib/node_modules/polymer-cli/node_modules/wd/node_modules/.bin:/usr/lib/node_modules/polymer-cli/node_modules/.bin:/usr/lib/node_modules/.bin:/usr/local/sbin:/usr/loc\
al/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
29580 verbose lifecycle wd@1.5.0~install: CWD: /usr/lib/node_modules/polymer-cli/node_modules/wd
29581 silly lifecycle wd@1.5.0~install: Args: [ '-c', 'node scripts/build-browser-scripts' ]
29582 silly lifecycle wd@1.5.0~install: Returned: code: 1  signal: null
29583 info lifecycle wd@1.5.0~install: Failed to exec install script
29584 verbose unlock done using /root/.npm/_locks/staging-a072192f34a17023.lock for /usr/lib/node_modules/.staging
29585 verbose stack Error: wd@1.5.0 install: `node scripts/build-browser-scripts`
29585 verbose stack Exit status 1
29585 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
29585 verbose stack     at EventEmitter.emit (events.js:160:13)
29585 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
29585 verbose stack     at ChildProcess.emit (events.js:160:13)
29585 verbose stack     at maybeClose (internal/child_process.js:943:16)
29585 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
29586 verbose pkgid wd@1.5.0

知道怎么解决吗?

更新

我将npmbower更新为最新版本,然后再次为polymer-cli运行install命令。现在我收到以下错误消息 - 运行脚本时这是一个权限问题。我不确定这是否属于npm安装脚本或者是否是一个arch linux问题。

sudo npm install -g polymer-cli

npm WARN deprecated babel-preset-es2015@6.24.1:   Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update! 
npm WARN deprecated bower@1.8.2: ...psst! Your project can stop working at any moment because its dependencies can change. Prevent this by migrating to Yarn: https://bower.io/blog/2017/how-to-migrate-away-from-bower/
npm WARN deprecated github@7.3.2: 'github' has been renamed to '@octokit/rest' (https://git.io/vNB11)
npm WARN deprecated @types/assert@0.0.29: See https://github.com/DefinitelyTyped/DefinitelyTyped/issues/12826
/usr/bin/polymer -> /usr/lib/node_modules/polymer-cli/bin/polymer.js

> uws@0.14.5 install /usr/lib/node_modules/polymer-cli/node_modules/uws
> node-gyp rebuild > build_log.txt 2>&1 || exit 0

sh: build_log.txt: Permission denied

> wd@1.5.0 install /usr/lib/node_modules/polymer-cli/node_modules/wd
> node scripts/build-browser-scripts

/usr/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:90
                    throw err0;
                    ^

Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/polymer-cli/node_modules/wd/build'
    at Object.fs.mkdirSync (fs.js:905:18)
    at sync (/usr/lib/node_modules/polymer-cli/node_modules/mkdirp/index.js:71:13)
    at Object.<anonymous> (/usr/lib/node_modules/polymer-cli/node_modules/wd/scripts/build-browser-scripts.js:6:1)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Function.Module.runMain (module.js:701:10)
    at startup (bootstrap_node.js:193:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! wd@1.5.0 install: `node scripts/build-browser-scripts`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the wd@1.5.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!     /root/.npm/_logs/2018-01-28T19_51_38_197Z-debug.log

现在的问题是脚本尝试创建此目录:

mkdir '/usr/lib/node_modules/polymer-cli/node_modules/wd/build'

2 个答案:

答案 0 :(得分:2)

  1. 使用--unsafe-perm选项全局安装Polymer-cli,如here
  2. 所述

    sudo npm install -g polymer-cli --unsafe-perm

    1. Change npm's Default Directory
    2. 然后在没有sudo和npm install -g polymer-cli选项的情况下安装--unsafe-perm

答案 1 :(得分:1)

切换到Yarn并安装!

<div class="col-md-6">
    <div class="panel panel-default">
        <div class="panel-heading" style="background-color:#f37735;color:white"><h3><b>Employment History</b>
        <button class="btn btn-primary btn-sm" type="button" style="float:right;" data-toggle="collapse" data-target="#collapseEmployment" aria-expanded="false" aria-controls="collapseEmployment">
            Show Items
        </button>
        </h3>
        </div>
   </div>
</div>