eggjs / egg

🥚 Born to build better enterprise frameworks and apps with Node.js & Koa
https://eggjs.org
MIT License
18.9k stars 1.82k forks source link

egg-ci 安装失败 #426

Closed johnnychq closed 7 years ago

johnnychq commented 7 years ago

egg部署生产时出现问题,直接原因是egg间接依赖了egg-ci,但egg-ci安装失败,windows/mac开发环境均可,但centos不可以,单独cnpm install egg-ci也失败。

[root@test-1-4 tmp]# cnpm install egg-ci
[          ........] \ loadExtraneous: sill resolveWithNewModule fsevents@1.1.1 checking installable status

> egg-ci@1.1.0 postinstall /home/cxinscn_cathay_portal/tmp/node_modules/egg-ci
> node install.js

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

Error: EACCES: permission denied, open '/home/cxinscn_cathay_portal/tmp/.travis.yml'
    at Error (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.writeFileSync (fs.js:1333:33)
    at Object.<anonymous> (/home/cxinscn_cathay_portal/tmp/node_modules/egg-ci/install.js:64:6)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
[                ..] / postinstall: info lifecycle egg-ci@1.1.0~postinstall: Failed to exec postinstall script
CathayPortal@0.0.1 /home/cxinscn_cathay_portal/tmp
├── UNMET PEER DEPENDENCY eslint@3.16.0
└─┬ react-native@0.34.0
  └─┬ yeoman-generator@0.21.2
    └─┬ html-wiring@1.2.0
      └─┬ cheerio@0.19.0 
        ├─┬ css-select@1.0.0 
        │ ├── css-what@1.0.0 
        │ └── domutils@1.4.3 
        └─┬ htmlparser2@3.8.3 
          ├── domutils@1.5.1 
          └── entities@1.0.0 

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN eslint-config-airbnb@9.0.1 requires a peer of eslint@^2.9.0 but none was installed.
npm WARN eslint-config-airbnb-base@3.0.1 requires a peer of eslint@^2.9.0 but none was installed.
npm WARN thunk-mocha@1.0.8 requires a peer of mocha@>=2 || >=3.0 but none was installed.
npm ERR! Linux 2.6.32-431.23.3.el6.x86_64
npm ERR! argv "/opt/node-v6.9.2-linux-x64/bin/node" "/opt/node-v6.9.2-linux-x64/bin/npm" "--registry=https://registry.npm.taobao.org" "--cache=/root/.npm/.cache/cnpm" "--disturl=https://npm.taobao.org/mirrors/node" "--userconfig=/root/.cnpmrc" "install" "egg-ci"
npm ERR! node v6.9.2
npm ERR! npm  v3.10.9
npm ERR! code ELIFECYCLE

npm ERR! egg-ci@1.1.0 postinstall: `node install.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the egg-ci@1.1.0 postinstall script 'node install.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the egg-ci package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node install.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs egg-ci
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls egg-ci
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/cxinscn_cathay_portal/tmp/npm-debug.log

运行命令时,直接是root身份,所以不明白为啥postinstall报权限问题

dead-horse commented 7 years ago
Error: EACCES: permission denied, open '/home/cxinscn_cathay_portal/tmp/.travis.yml'

权限问题,你看一下文件系统权限。

能知道是哪个模块在 dependencies 里面写了 egg-ci 么?

dead-horse commented 7 years ago

是你自己在 devDependencies 引的 egg-ci 啊,然后我看生成的 travis 文件地址也是到你的项目目录的。

解决方案:

  1. 如果你不需要在 github 上跑 CI,去掉 egg-ci 的引用
  2. 生产环境安装的时候 cnpm install --production,不安装 devDepencencies
  3. 修正权限问题
johnnychq commented 7 years ago

devDependencies直接依赖了egg-ci,这个是以前脚手架里复制过来的,没特别留意,删除后解决。

但还是不能解释为什么root身份cnpm install egg-ci会报上述错误(但win,mac又没问题)的问题。

------seperate line-------

刚又排查了权限问题,当前用户虽然是root,但当前文件夹的权限为dr-xr-xr-x,所以即使默认root也无法执行。

谢谢dead-horse帮忙排查

johnnychq commented 7 years ago

其实安装devDependencies是为了浏览器端Antd静态资源编译打包的,我们项目偷懒,服务端依赖和前端依赖没分开。刚才操作的机器是测试环境编译机,做antd静态资源打包的。