如何在弹性豆茎中安装咕噜声?

时间:2015-03-04 20:35:03

标签: node.js gruntjs elastic-beanstalk

我尝试使用beanstalk部署我的应用。我用grunt dev开始我的本地环境。错误显示无法找到grunt。

使用eb ssh登录服务器后,我发现npm也未安装。

我正在寻找解决此问题的后续步骤。

.ebextensions / 01_grunt.config

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: NodeCommand
    value: "grunt dev"

eb日志

...
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
Wed, 04 Mar 2015 19:07:54 GMT express deprecated res.sendfile: Use res.sendFile instead at server.js:6:7
static file request : [object Object]
Wed, 04 Mar 2015 19:07:54 GMT express deprecated res.sendfile: Use res.sendFile instead at server.js:12:7
Error: ENOENT, stat '/var/app/current/libs/bootstrap-css/css/bootstrap.css'
static file request : [object Object]
static file request : [object Object]
Error: ENOENT, stat '/var/app/current/dist/libs.js'
Error: ENOENT, stat '/var/app/current/dist/app.js'
static file request : [object Object]
Error: ENOENT, stat '/var/app/current/favicon.ico'
static file request : [object Object]
Error: ENOENT, stat '/var/app/current/favicon.ico'
Listening on 8081

sh: grunt: command not found
sh: grunt: command not found
sh: grunt: command not found
sh: grunt: command not found
...

更新

尝试: .ebextensions / 01_grunt.config (请注意 npm install

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: NodeCommand
    value: "npm install && grunt dev"

eb日志

npm ERR! System Linux 3.14.27-25.47.amzn1.x86_64
npm ERR! command "/opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/bin/node" "/opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/bin/npm" "install" "&&" "grunt" "dev"
npm ERR! cwd /var/app/current
npm ERR! node -v v0.10.31
npm ERR! npm -v 1.4.23
npm ERR! Error: Attempt to unlock grunt, which hasn't been locked
npm ERR!     at unlock (/opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/lib/node_modules/npm/lib/utils/locker.js:44:11)
npm ERR!     at cb (/opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/lib/node_modules/npm/lib/cache/add-local.js:30:5)
npm ERR!     at /opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/lib/node_modules/npm/lib/cache/add-local.js:47:20
npm ERR!     at /opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/lib/node_modules/npm/lib/utils/locker.js:30:7
npm ERR!     at /opt/elasticbeanstalk/node-install/node-v0.10.31-linux-x64/lib/node_modules/npm/node_modules/lockfile/lockfile.js:167:38
npm ERR!     at Object.oncomplete (fs.js:107:15)

1 个答案:

答案 0 :(得分:5)

没有理由让BeanStalk运行grunt。这增加了一个不必要的失败点。

您应该提供已编译的资产,并使用正确的命令添加npm start脚本以启动您的应用。

例如,在package.json

{
  "name": "myApp",
  "version": "1.0.0",
  "scripts": {
    "start": "node myApp.js"
  }
}

如果你真的想要它,你可以添加grunt-cli作为依赖项,并使用node_modules/grunt-cli/bin/grunt中的bin来运行它。但是,请:不要!