Egg: npm i 出错

Created on 14 Jan 2019  ·  4Comments  ·  Source: eggjs/egg

$ npm i egg-init -g
$ egg-init egg-example --type=simple
$ cd egg-example
$ npm i

执行上面的命令,出现了以下错误

npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: CircularJSON is in maintenance only, flatted is its successor.
npm WARN deprecated [email protected]: If using 2.x branch, please upgrade to at least 2.1.6 to avoid a serious bug with socket data flow and an import issue introduced in 2.1.0

> [email protected] postinstall /home/ubuntu/egg-example/node_modules/egg-ci
> node install.js

fs.js:121
    throw err;
    ^

Error: EACCES: permission denied, open '/home/ubuntu/egg-example/.travis.yml'
    at Object.openSync (fs.js:450:3)
    at Object.writeFileSync (fs.js:1212:35)
    at Object.<anonymous> (/home/ubuntu/egg-example/node_modules/egg-ci/install.js:119:6)
    at Module._compile (internal/modules/cjs/loader.js:721:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:732:10)
    at Module.load (internal/modules/cjs/loader.js:620:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
    at Function.Module._load (internal/modules/cjs/loader.js:552:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
    at executeUserCode (internal/bootstrap/node.js:342:17)
npm WARN [email protected] requires a peer of mocha@>=1.18 <6 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of typescript@>= 2.4.2 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall 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/2019-01-14T06_56_08_575Z-debug.log

系统的版本 Ubuntu 16.04 和 Ubuntu 18.04 都是这个问题
node 和 npm 换了几个版本也都是这个问题

发现有类似的问题 https://github.com/eggjs/egg/issues/2442

Most helpful comment

@jasontsai1990 亲测,可以试试这个,
npm i --unsafe-perm=true --allow-root

All 4 comments

补充:操作是 root 用户,理论上没有权限问题

到这一步已经是 Node 的问题了,跟 egg 没关系了。

如果你不需要就把 egg-ci 从依赖中干掉。

@jasontsai1990 亲测,可以试试这个,
npm i --unsafe-perm=true --allow-root

你是不是在 windows 子系统(wsl1)里执行的这个命令?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xcstream picture xcstream  ·  3Comments

Azard picture Azard  ·  3Comments

lvgg3271 picture lvgg3271  ·  3Comments

popomore picture popomore  ·  3Comments

bupafengyu picture bupafengyu  ·  3Comments