Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用egg-init创建simple项目后,执行npm install时安装egg-ci报错。 #2442

Closed
sadcity opened this issue Apr 21, 2018 · 19 comments
Closed

Comments

@sadcity
Copy link

sadcity commented Apr 21, 2018

  • Node Version:8.9.3
  • Egg Version:
  • Plugin Name:
  • Plugin Version:
  • Platform:linux
  • Mini Showcase Repository:
@egg-bot
Copy link

egg-bot commented Apr 21, 2018

Translation of this issue:


After creating a simple project with egg-init, install egg-ci when npm install is executed.

  • Node Version:
  • Egg Version:
  • Plugin Name:
  • Plugin Version:
  • Platform:
  • Mini Showcase Repository:

@atian25
Copy link
Member

atian25 commented Apr 21, 2018

where is error message?

@egg-bot
Copy link

egg-bot commented Apr 28, 2018

Hello @sadcity. Please provide a reproducible example by creating a github repo.

Issues labeled by Need Reproduce will be closed if no activities in 7 days.

@bi-kai
Copy link

bi-kai commented May 15, 2018

@atian25 @popomore
应该就是这个提示吧,egg-init执行npm i时的报错:

> egg-ci@1.8.0 postinstall /starlab/www/test/node/egg-example/node_modules/egg-ci
> node install.js

fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/starlab/www/test/node/egg-example/.travis.yml'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at Object.<anonymous> (/starlab/www/test/node/egg-example/node_modules/egg-ci/install.js:87:6)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:188:16)
npm WARN co-mocha@1.2.2 requires a peer of mocha@>=1.18 <6 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! egg-ci@1.8.0 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the egg-ci@1.8.0 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!     /starlab/server/node-cache/_logs/2018-05-15T08_20_56_284Z-debug.log

虽然没什么影响,只是ci跑不通,但是安装模块就报这个错,提示出来也不合适,可以给些说明或者规避的提醒。

@atian25
Copy link
Member

atian25 commented May 15, 2018

Error: EACCES: permission denied

@bi-kai
Copy link

bi-kai commented May 15, 2018

@atian25 并不是权限的问题,是文件根本不存在。
image

@atian25
Copy link
Member

atian25 commented May 15, 2018

这是 egg-ci 的 postinstall 里面会复制文件到你的项目目录下,写入的目标地址是 '/starlab/www/test/node/egg-example/.travis.yml' ,没有权限,写入失败,自然你 ls 不到

@bi-kai
Copy link

bi-kai commented May 15, 2018

@atian25 我是用root运行的,为什么还会权限不足呢~

win上确实有这个文件:
image

@atian25
Copy link
Member

atian25 commented May 15, 2018

不确定,这属于系统问题。

@shiny
Copy link
Contributor

shiny commented Sep 14, 2018

遇到了同样的问题,用户是 root,运行于 ubuntu server 上,出错时 .travis.yml 文件也不存在

egg-init projectname --type=simple
cd projectname/
npm i

报错内容:

npm WARN deprecated postinstall-build@5.0.3: postinstall-build's behavior is now built into npm! You should migrate off of postinstall-build and use the new `prepare` lifecycle script with npm 5.0.0 or greater.
npm WARN deprecated socks@1.1.10: 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

> nunjucks@3.1.3 postinstall /data/projectname/node_modules/nunjucks
> node postinstall-build.js src


> egg-ci@1.8.0 postinstall /data/projectname/node_modules/egg-ci
> node install.js

fs.js:145
    throw err;
    ^

Error: EACCES: permission denied, open '/data/projectname/.travis.yml'
    at Object.fs.openSync (fs.js:579:3)
    at Object.fs.writeFileSync (fs.js:1309:33)
    at Object.<anonymous> (/data/projectname/node_modules/egg-ci/install.js:87:6)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:744:10)
    at startup (internal/bootstrap/node.js:238:19)
npm WARN co-mocha@1.2.2 requires a peer of mocha@>=1.18 <6 but none is installed. You must install peer dependencies yourself.
npm WARN espower-typescript@9.0.1 requires a peer of typescript@>= 2.4.2 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! egg-ci@1.8.0 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the egg-ci@1.8.0 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/2018-09-14T09_51_09_574Z-debug.log

@shiny
Copy link
Contributor

shiny commented Sep 14, 2018

尝试单独 npm 安装

npm i egg-ci --save

也会有同样的报错

测试1:

如果单独写个 js

const fs = require('fs');
fs.writeFileSync('/data/projectname/.travis.yml', 'test');

又能正常创建文件

测试2

egg-init testname  --type=simple
cd testname/
npm i egg-ci --save

也会出错

测试4

先 touch .travis.yml,赋予 777 权限,就能接下去运行了。
可能是因为脚本的运行权限不够导致的

@BaffinLee
Copy link
Contributor

这是 npm 的机制吧,看看 npm 文档 https://docs.npmjs.com/misc/scripts#user

If npm was invoked with root privileges, then it will change the uid to the user account or uid specified by the user config, which defaults to nobody. Set the unsafe-perm flag to run scripts with root privileges.

@bi-kai
Copy link

bi-kai commented Sep 18, 2018

I hope this could be fixed by all means.

@ssehacker
Copy link

+1, 在centos上运行这个命令就报错了

[root@18687a9a3eff delta]# npm i egg-ci --save

> nunjucks@3.1.3 postinstall /root/project/delta/node_modules/nunjucks
> node postinstall-build.js src


> egg-ci@1.10.0 postinstall /root/project/delta/node_modules/egg-ci
> node install.js

fs.js:652
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: EACCES: permission denied, open '/root/project/delta/.travis.yml'
    at Object.fs.openSync (fs.js:652:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at Object.<anonymous> (/root/project/delta/node_modules/egg-ci/install.js:119:6)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
    at Function.Module.runMain (module.js:609:10)
    at startup (bootstrap_node.js:158:16)
npm WARN co-mocha@1.2.2 requires a peer of mocha@>=1.18 <6 but none was installed.
npm WARN espower-typescript@9.0.1 requires a peer of typescript@>= 2.4.2 but none was installed.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! egg-ci@1.10.0 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the egg-ci@1.10.0 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/2018-10-20T14_59_46_348Z-debug.log

@atian25
Copy link
Member

atian25 commented Oct 20, 2018

权限问题

@ManfredHu
Copy link

因为服务器就是我的,只有一个root用户。系统CentOS

chmod 777 项目目录/

@realred
Copy link

realred commented Aug 15, 2019

用这个命令 npm install --unsafe-perm

@JasenWu
Copy link

JasenWu commented Oct 27, 2020

用这个命令 npm install --unsafe-perm 解决了

@yilikun
Copy link

yilikun commented Aug 26, 2022

npm install --unsafe-perm
这个参数在 npm v6.11.0 中被标记为废弃、在 v7.0.0 中被移除,已经无需指定,现在运行时是哪个用户就是哪个用户。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests