简体   繁体   中英

Unable to deploy a Nodejs application to Heroku (bower not found)

I've looked through similar stackoverflow questions and none of them seem to work for me. I've been trying to deploy my NodeJS app to Heroku but keep bumping into this message from heroku regarding bower. I have tried manually writing bower in my dependencies but that has not worked, I also tried moving my dependencies from bower.json to package.json but that also didn't work. Thank you guy so much, I have put my heroku logs, package.json, and bower.json files below.

angular-seed@0.0.0 postinstall /tmp/build_370f51a52877a36d300c739f31855511 remote: > bower install remote:
remote: sh: 1: bower: not found

I have listed below my package.json and my bower.json files.

Package.json

"name": "angular-seed",
"private": true,
"version": "0.0.0",
"description": "A starter project for AngularJS",
"repository": "https://github.com/angular/angular-seed",
"license": "MIT",
"devDependencies": {
"bower": "^1.7.7",
"http-server": "^0.9.0",
"jasmine-core": "^2.4.1",
"karma": "^0.13.22",
"karma-chrome-launcher": "^0.2.3",
"karma-firefox-launcher": "^0.1.7",
"karma-jasmine": "^0.3.8",
"karma-junit-reporter": "^0.4.1",
"protractor": "^3.2.2"
  },
  "scripts": {
"postinstall": "bower install",

"prestart": "npm install",
"start": "http-server -a localhost -p 8000 -c-1 ./app",

"pretest": "npm install",
"test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run",

"preupdate-webdriver": "npm install",
"update-webdriver": "webdriver-manager update",

"preprotractor": "npm run update-webdriver",
"protractor": "protractor e2e-tests/protractor.conf.js",
},
"dependencies":{
"bower": "^1.7.9"
}
}

Bower.json

{
  "name": "angular-seed",
  "description": "A starter project for AngularJS",
  "version": "0.0.0",
  "homepage": "https://github.com/angular/angular-seed",
  "license": "MIT",
  "private": true,
  "dependencies": {
"angular": "~1.5.0",
"angular-route": "~1.5.0",
"angular-loader": "~1.5.0",
"angular-mocks": "~1.5.0",
"html5-boilerplate": "^5.3.0"
  }
}

Heroku

remote: -----> Creating runtime environment
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NPM_CONFIG_PRODUCTION=true
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote: -----> Installing binaries
remote:        engines.node (package.json):  unspecified
remote:        engines.npm (package.json):   unspecified (use default)
remote:        Resolving node version (latest stable) via semver.io...
remote:        Downloading and installing node 5.11.1...
remote:        Using default npm version: 3.8.6
remote: -----> Restoring cache
remote:        Skipping cache restore (new runtime signature)
remote: -----> Building dependencies
remote:        Installing node modules (package.json)
remote:        > angular-seed@0.0.0 postinstall /tmp/build_73e84e8327fb8bcb9b0e1cdc47631bca
remote:        > bower install
remote:        sh: 1: bower: not found
remote:        npm ERR! Linux 3.13.0-95-generic
remote:        npm ERR! argv
/tmp/build_73e84e8327fb8bcb9b0e1cdc47631bca/.heroku/node/bin/node" "/tmp/build_73e84e8327fb8bcb9b0e1cdc47631bca/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_73e84e8327fb8bcb9b0e1cdc47631bca/.npmrc"
remote:        npm ERR! node v5.11.1
remote:        npm ERR! npm  v3.8.6
remote:        npm ERR! file sh
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno ENOENT
remote:        npm ERR! syscall spawn
remote:        npm ERR! angular-seed@0.0.0 postinstall: `bower install`
remote:        npm ERR! spawn ENOENT
remote:        npm ERR!
remote:        npm ERR! Failed at the angular-seed@0.0.0 postinstall script 
bower install'.
remote:        npm ERR! Make sure you have the latest version of node.js and npm installed.
remote:        npm ERR! If you do, this is most likely a problem with the angular-seed package,
remote:        npm ERR! not with npm itself.
remote:        npm ERR! Tell the author that this fails on your system:
remote:        npm ERR!     bower install
remote:        npm ERR! You can get information on how to open an issue for this project with
remote:        npm ERR!     npm bugs angular-seed
remote:        npm ERR! Or if that isn't available, you can get their info via:
remote:        npm ERR!     npm owner ls angular-seed
remote:        npm ERR! There is likely additional logging output above.
remote:        npm ERR! Please include the following file with any support
remote:        npm ERR!     /tmp/build_73e84e8327fb8bcb9b0e1cdc47631bca/npm-debug.log
remote: -----> Build failed

Try this instead for the postinstall:

"postinstall": "./node_modules/bower/bin/bower install"

This is because bower is installed locally in the specified path, not globally.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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