【发布时间】:2017-11-09 04:27:14
【问题描述】:
情况
我有一个使用 npm、bower 和 gulp 作为前端的 Laravel (5.4) 应用程序。
我在部署时已成功配置所有内容,但 npm install 或 npm install --production(在我的情况下是相同的)命令给我错误并使部署失败。
问题
当我运行eb deploy 命令时,这是来自 AWS 的“原因”响应。
Application update failed at 2017-06-07T17:08:38Z with exit status 1 and error: container_command 01-npm-install in .ebextensions/05-frontend-install.config failed.
npm WARN lifecycle npm is using /usr/bin/node but there is no node binary in the current PATH. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@1.0.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN prefer global node-gyp@3.6.2 should be installed with -g
npm WARN prefer global marked@0.3.6 should be installed with -g
> node-sass@3.13.1 install /var/app/ondeck/node_modules/node-sass
> node scripts/install.js
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! node-sass@3.13.1 install: `node scripts/install.js`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the node-sass@3.13.1 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/2017-06-07T17_08_38_740Z-debug.log.
Incorrect application version "app-5d9c-170607_190633" (deployment 40). Expected version "app-0466-170606_110037" (deployment 31).
.ebextensions/05-frontend-install.config 文件有这个内容
container_commands:
00-npm-upgrade:
command: "npm install -g npm@latest"
01-npm-install:
command: "npm install --production"
02-gulp-install:
command: "sudo npm install gulp"
03-bower-install:
command: "sudo npm install bower"
04-bower-deploy:
command: "sudo bower install --allow-root"
05-gulp-deploy:
command: "sudo npm run prod"
【问题讨论】:
-
为什么需要 gulp 和 bower 来运行 prod?
-
@SamH。
sudo npm run prod等于我的package.json中的sudo gulp --production,它将所有 js 和所有 css 压缩到 2 个文件中以用于生产。一些资产是自定义的,一些资产是依赖项(甚至来自 bower) -
我想我的意思是,你为什么不在 CI/CD 服务器上执行此操作,然后
eb deploy? -
在我的情况下,我在 gitlab 上有 repo,我进行了测试-> 部署登台 |部署生产(手动),所以您建议在 gitlab 容器构建中进行 css js 操作,然后全部压缩并部署到 aws 的暂存/生产?我没有考虑过,但我会试一试。谢谢@SamH。
-
Uuuh ...我正在尝试这个,但它会很棘手 - 我不喜欢这个解决方案
标签: node.js laravel amazon-web-services deployment amazon-elastic-beanstalk