簡體   English   中英

AWS - 通過npm install安裝bower組件

[英]AWS - Installing bower components via npm install

我正在嘗試使用git aws.push方法啟動node.js服務器

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

與此解決方案類似,我正在嘗試運行'bower install',盡管我的解決方案有點不同:

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

我的實施:

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

這在本地工作正常 - npm安裝也運行bower安裝沒有問題。 當我部署到aws時,npm運行正常 - 我知道我的服務器啟動正常,因為我可以在日志中看到來自它的消息,但是當我嘗試啟動客戶端時,沒有任何涼亭組件到位。

我正在使用節點v0.10.26,我確信我的本地計算機上沒有全局安裝bower。 我已經在package.json的依賴項部分中嘗試了這個,包括和不包括bower。

有任何想法嗎? 並提前感謝。

的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"
  }
}

日志文件

整個日志太長了,但如果需要,我會將其粘貼到多個注釋中。 以下是唯一提到涼亭的部分。

如果我嘗試訪問該站點,我可以獲得訪問日志,指示缺少bower組件。

似乎沒有執行bower安裝的任何執行。


/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 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 /一次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

涼亭可能沒有全球安裝(如果是,請告訴我如何在彈性豆莖上做到這一點:D)。 您應該在node_modules文件夾中指向bower的bin(這是我們以前的做法)。 我們已經放棄了那個解決方案(考慮它是500個實例的規模......)並且正在檢查bower_components到repo中。

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

將.config文件添加到.ebextensions dir以安裝bower組件會有所幫助。 遺憾的是,默認情況下node和npm不會添加到路徑中,因此您需要查找最新的節點實例並創建符號鏈接。 我真的不喜歡以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"

使用$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不一定使用最新版本的nodenpm

例如...

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

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

即使它確實如此,也可能不是你想要的。

您可以通過排序來解決這個問題,但您仍然可能希望使用與環境相同的節點版本,可以通過$NODE_HOME訪問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM