简体   繁体   English

AWS - 通过npm install安装bower组件

[英]AWS - Installing bower components via npm install

I am trying to spin up a node.js server using the git aws.push method 我正在尝试使用git aws.push方法启动node.js服务器

http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_nodejs.sdlc.html

Similar to this solution, I'm trying to run 'bower install', though my solution is a bit different: 与此解决方案类似,我正在尝试运行'bower install',尽管我的解决方案有点不同:

https://developer.ibm.com/answers/questions/16594/how-to-install-packages-on-nodejs/ https://developer.ibm.com/answers/questions/16594/how-to-install-packages-on-nodejs/

my implementation: 我的实施:

"scripts": { "postinstall": "bower install -F" }, “scripts”:{“postinstall”:“bower install -F”},

this works fine locally - npm install also runs bower install with no problems. 这在本地工作正常 - npm安装也运行bower安装没有问题。 when i deploy to aws, npm runs fine - i know that my server starts up fine because i can see messages from it in the logs, but none of the bower components are in place when i try to bring up the client. 当我部署到aws时,npm运行正常 - 我知道我的服务器启动正常,因为我可以在日志中看到来自它的消息,但是当我尝试启动客户端时,没有任何凉亭组件到位。

i'm using node v0.10.26, and i am sure that i don't have bower installed globally on my local machine. 我正在使用节点v0.10.26,我确信我的本地计算机上没有全局安装bower。 i've tried this both with and without including bower in the dependencies section of my package.json. 我已经在package.json的依赖项部分中尝试了这个,包括和不包括bower。

any ideas? 有任何想法吗? and thanks in advance. 并提前感谢。

package.json 的package.json

{
  "name": "smf",
  "version": "0.1.0",
  "dependencies": {
    "aws-sdk": "~2.0.0-rc.14",
    "base64-js": "0.0.6",
    "bookshelf": "~0.6.10",
    "bower": "*",
    "change-case": "~2.1.1",
    "crypto-js": "~3.1.2-3",
    "geojson": "~0.1.5",
    "handlebars": "~2.0.0-alpha.2",
    "js-base64": "~2.1.5",
    "lodash": "~2.4.1",
    "mathjs": "~0.21.0",
    "minify": "~0.5.1",
    "moment": "~2.6.0",
    "newrelic": "~1.5.3",
    "node-cryptojs-aes": "~0.4.0",
    "node-highcharts": "0.0.2",
    "node-uuid": "~1.4.1",
    "passport": "~0.2.0",
    "passport-http": "~0.2.2",
    "passport-local": "~1.0.0",
    "password-hash": "~1.2.2",
    "pg": "~3.0.3",
    "restify": "~2.7.0",
    "should": "~3.3.1",
    "socket.io": "~0.9.16",
    "sqlite3": "~2.2.3",
    "util": "~0.10.3",
    "when": "~3.1.0"
  },
  "devDependencies": {
    "grunt": "~0.4.2",
    "grunt-contrib-jshint": "^0.10.0",
    "grunt-mocha-test": "~0.9.0",
    "mocha-phantomjs": "~3.3.1"
  },
  "scripts": {
    "postinstall": "bower install -F"
  },
  "engines": {
    "node": ">=0.6"
  }
}

LOG FILES 日志文件

The entire log is too long, though I will paste it in multiple comments if you need. 整个日志太长了,但如果需要,我会将其粘贴到多个注释中。 Below is the only section that mentions bower at all. 以下是唯一提到凉亭的部分。

If I try to access the site, I can get access logs indicating that bower components are missing. 如果我尝试访问该站点,我可以获得访问日志,指示缺少bower组件。

There doesn't appear to be any execution of bower install happening. 似乎没有执行bower安装的任何执行。


/var/log/directory-hooks-executor.log /var/log/directory-hooks-executor.log

underscore.string@2.3.3 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string esprima@1.0.4 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/node_modules/esprima object-assign@0.3.1 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/object-assign uuid@1.4.1 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/uuid latest-version@0.2.0 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version package-json@0.2.0 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json got@0.3.0 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_m underscore.string@2.3.3 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/configstore/node_modules/js-yaml/node_modules/argparse/node_modules/underscore.string esprima@1.0.4 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / configstore / node_modules / js-yaml / node_modules / esprima object-assign@0.3.1 / tmp / deployment / application / node_modules / bower / node_modules / update- notifier / node_modules / configstore / node_modules / object-assign uuid@1.4.1 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / configstore / node_modules / uuid latest-version@0.2.0 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version package-json@0.2.0 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package -json got@0.3.0 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_m odules/latest-version/node_modules/package-json/node_modules/got object-assign@0.3.1 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/got/node_modules/object-assign registry-url@0.1.1 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url npmconf@2.0.2 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf config-chain@1.1.8 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/config-chain proto-list@1.2.3 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_m odules / latest-version / node_modules / package -json / node_modules / got object-assign@0.3.1 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_modules / got / node_modules / object-assign registry-url@0.1.1 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_modules / registry- url npmconf@2.0.2 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_modules / registry-url / node_modules / npmconf config-chain@1.1。 8 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_modules / registry-url / node_modules / npmconf / node_modules / config-chain proto-list@1.2 .3 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_m odules/registry-url/node_modules/npmconf/node_modules/config-chain/node_modules/proto-list ini@1.2.1 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/ini inherits@2.0.1 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/inherits mkdirp@0.3.5 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/mkdirp once@1.3.0 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/once uid-number@0.0.5 /tmp/deployment/application/node_modules/bower/node_module odules / registry-url / node_modules / npmconf / node_modules / config-chain / node_modules / proto-list ini@1.2.1 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package -json / node_modules / registry-url / node_modules / npmconf / node_modules / ini inherits@2.0.1 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package- json / node_modules / registry-url / node_modules / npmconf / node_modules / inherits mkdirp@0.3.5 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_modules / registry-url / node_modules / npmconf / node_modules / mkdirp once@1.3.0 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / latest-version / node_modules / package-json / node_modules / registry- url / node_modules / npmconf / node_modules /一次uid-number@0.0.5 / tmp / deployment / application / node_modules / bower / node_module s/update-notifier/node_modules/latest-version/node_modules/package-json/node_modules/registry-url/node_modules/npmconf/node_modules/uid-number semver-diff@0.1.0 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/semver-diff string-length@0.1.2 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/string-length strip-ansi@0.2.2 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/string-length/node_modules/strip-ansi ansi-regex@0.1.0 /tmp/deployment/application/node_modules/bower/node_modules/update-notifier/node_modules/string-length/node_modules/strip-ansi/node_modules/ansi-regex which@1.0.5 /tmp/deployment/application/node_modules/bower/node_modules/which s / update-notifier / node_modules / latest-version / node_modules / package -json / node_modules / registry-url / node_modules / npmconf / node_modules / uid-number semver-diff@0.1.0 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / semver-diff string-length@0.1.2 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / string-length strip-ansi@0.2.2 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / string-length / node_modules / strip-ansi ansi-regex@0.1.0 / tmp / deployment / application / node_modules / bower / node_modules / update-notifier / node_modules / string-length / node_modules / strip-ansi / node_modules / ansi-regex which@1.0.5 / tmp / deployment / application / node_modules / bower / node_modules / which

bower is probably not installed globally (if it is, please tell me how to do that on elastic beanstalk :D ). 凉亭可能没有全球安装(如果是,请告诉我如何在弹性豆茎上做到这一点:D)。 You should instead point to the bin of bower in the node_modules folder (which is how we used to do it). 您应该在node_modules文件夹中指向bower的bin(这是我们以前的做法)。 We have turned away from that solution (consider it at a scale of 500 instances spinning up..) and are checking bower_components into the repo. 我们已经放弃了那个解决方案(考虑它是500个实例的规模......)并且正在检查bower_components到repo中。

"scripts": {
  "postinstall": "node_modules/bower/bin/bower install -F"
},

Adding a .config file to your .ebextensions dir to install bower components helps. 将.config文件添加到.ebextensions dir以安装bower组件会有所帮助。 Unfortunately, node and npm are not added to the path by default so you need to find the latest node instance and create a symlink. 遗憾的是,默认情况下node和npm不会添加到路径中,因此您需要查找最新的节点实例并创建符号链接。 I'm really not a fan of installing the bower components as root but this'll work: 我真的不喜欢以root用户身份安装bower组件,但这样做有用:

commands:
  01_get_sudo:
      command: echo Defaults:root \!requiretty >> /etc/sudoers
  02_node_path:
    command: "sudo ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /usr/bin/node"
  03_npm_path:
    command: "sudo ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/npm /usr/bin/npm"

container_commands:
  01_bower_install:
    command: "sudo ./node_modules/bower/bin/bower install --allow-root"

Use $NODE_HOME , eg 使用$NODE_HOME ,例如

container_commands:
  01_bower_install:
    command: "export PATH=$PATH; $NODE_HOME/bin/node ./node_modules/bower/bin/bower install --allow-root &>> /tmp/01_bower_install.log"

head -1 will not necessarily use the most recent version of node and npm . head -1不一定使用最新版本的nodenpm

For example... 例如...

$ ls -td /opt/elasticbeanstalk/node-install/node-* | head -1
/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64

whereas ls shows that v5.6.0 is actually the most recent: ls表明v5.6.0实际上是最新的:

$ ls -td /opt/elasticbeanstalk/node-install/node-*
/opt/elasticbeanstalk/node-install/node-v4.3.0-linux-x64
/opt/elasticbeanstalk/node-install/node-v0.10.42-linux-x64
/opt/elasticbeanstalk/node-install/node-v5.6.0-linux-x64
/opt/elasticbeanstalk/node-install/node-v0.8.28-linux-x64
/opt/elasticbeanstalk/node-install/node-v0.12.10-linux-x64

Even if it did, it's probably not what you want. 即使它确实如此,也可能不是你想要的。

You can get around this by sorting, but you still probably want to use the same node version as the environment, which can be accessed via $NODE_HOME . 您可以通过排序来解决这个问题,但您仍然可能希望使用与环境相同的节点版本,可以通过$NODE_HOME访问。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM