Node.js 如何在弹性豆茎中安装grunt?

Node.js 如何在弹性豆茎中安装grunt?,node.js,gruntjs,amazon-elastic-beanstalk,Node.js,Gruntjs,Amazon Elastic Beanstalk,我正在尝试使用beanstalk部署我的应用程序。我用grunt dev启动本地环境。错误显示找不到grunt 使用eb-ssh登录到服务器后,我发现npm也没有安装 我正在寻找解决此问题的下一步措施 .ebextensions/01\u grunt.config option_settings: - namespace: aws:elasticbeanstalk:container:nodejs option_name: NodeCommand value: "grunt

我正在尝试使用beanstalk部署我的应用程序。我用
grunt dev
启动本地环境。错误显示找不到grunt

使用
eb-ssh
登录到服务器后,我发现
npm
也没有安装

我正在寻找解决此问题的下一步措施

.ebextensions/01\u grunt.config

option_settings:
  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: NodeCommand
    value: "grunt dev"
电子商务日志

...
-------------------------------------
/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
...
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)
更新:

已尝试:.ebextensions/01\u grunt.config(注意npm安装

电子商务日志

...
-------------------------------------
/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
...
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)

没有理由让BeanStalk运行
grunt
。这增加了不必要的故障点

您应该交付已编译的资产,并使用正确的命令添加
npm start
脚本以启动应用程序

例如,在您的
包.json
中:

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

但是,如果您确实想要它,您可以添加
grunt cli
作为依赖项,并使用
node\u modules/grunt cli/bin/grunt
中的bin来运行它。但是,请不要

没有理由让你的BeanStalk运行
grunt
。这增加了不必要的故障点

您应该交付已编译的资产,并使用正确的命令添加
npm start
脚本以启动应用程序

例如,在您的
包.json
中:

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

但是,如果您确实想要它,您可以添加
grunt cli
作为依赖项,并使用
node\u modules/grunt cli/bin/grunt
中的bin来运行它。但是,请不要

EB将为您运行
npm install
,但grunt不会全局安装,因为您的开发环境中可能有grunt。按此顺序运行
app.js
index.js
npm start
。您可以使用
npm start
或JS文件启动吗?@JamesWing我可以,但是我的
gruntfile
创建了一个
app.JS
和一个
lib.JS
文件,这两个文件在我的
中都被忽略。我认为eb不会复制git忽略的文件。正确吗?我理解,但我同意@firstdoit的回答--
grunt dev
可能不太适合EB。EB将为您运行
npm install
,但grunt不会被全局安装,因为您可能在您的开发环境中安装了它。按此顺序运行
app.js
index.js
npm start
。您可以使用
npm start
或JS文件启动吗?@JamesWing我可以,但是我的
gruntfile
创建了一个
app.JS
和一个
lib.JS
文件,这两个文件在我的
中都被忽略。我认为eb不会复制git忽略的文件。对吗?我理解,但我同意@firstdoit的答案--
grunt dev
可能不太适合EB。我同意。我将根据这种方法定制我的应用程序。你能解释为什么交付编译的资产比在EB上运行任务更好吗?我同意。我将根据这种方法定制我的应用程序。你能解释为什么交付编译的资产比在EB上运行任务更好吗?