2016-07-31 103 views
0

我的應用程序在本地工作,並且結構如下:問題部署的Node.js應用MEAN到Heroku的

MyApp 
    >package.json 
    >npm-debug.log 
    >readme.md 
    >client 
    >app 
    >node_modules 
    >public 
    >views 
    >bower.json 
    >Gruntfile.js 
    >package.json 
    >server 
    >config 
    >models 
    >node_modules 
    >routes 
    >app.js 
    >package.json 

部署到Heroku的結果在應用程序錯誤。日誌似乎表明了一個與bcrypt依賴關係和一些Mongoose模塊的問題。我是否需要使用MongoLabs這樣的應用程序才能在Heroku上工作?另外,我對package.json有些困惑,我不確定是否已經正確實現了它。我有一個package.json在我的根目錄中,在我的客戶端目錄和服務器目錄中。

的package.json在根:

{ 
    "name": "*****", 
    "version": "1.0.0", 
    "description": "******", 
    "main": "app.js", 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    }, 
    "author": "******", 
    "license": "ISC", 
    "dependencies": { 
    "bcrypt": "^0.8.5", 
    "body-parser": "^1.13.2", 
    "connect-flash": "^0.1.1", 
    "cookie-parser": "^1.3.5", 
    "ejs": "^2.3.3", 
    "express": "^4.13.1", 
    "express-session": "^1.11.3", 
    "mongoose": "^4.1.0", 
    "mongoskin": "^1.3.20", 
    "morgan": "^1.6.1", 
    "passport": "^0.2.2", 
    "passport-local": "^1.0.0" 
    } 
} 

和,在的package.json /客戶:

{ 
    "name": "****", 
    "version": "1.0.0", 
    "description": "******", 
    "main": "Gruntfile.js", 
    "directories": { 
    "test": "tests" 
    }, 
    "dependencies": { 
    "grunt": "^0.4.5" 
    }, 
    "devDependencies": { 
    "grunt-contrib-concat": "^0.5.1", 
    "grunt-contrib-watch": "^0.6.1" 
    }, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1" 
    } 
} 

Heroku的日誌

{ 
    "name": "****", 
    "version": "1.0.0", 
    "description": "****", 
    "engines": { 
    "node": "4.4.7" 
    }, 
    "scripts": { 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "start": "cd server && node app.js" 
    }, 
    "author": "*****", 
    "license": "ISC" 
} 

在/服務器的package.json:

2016-07-31T23:12:37.522131+00:00 app[web.1]:  ^
2016-07-31T23:12:37.522130+00:00 app[web.1]:   throw e 
2016-07-31T23:12:37.522133+00:00 app[web.1]: Error: /app/server/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header 
2016-07-31T23:12:37.522132+00:00 app[web.1]: 
2016-07-31T23:12:37.522134+00:00 app[web.1]:  at Error (native) 
2016-07-31T23:12:37.522136+00:00 app[web.1]:  at Module.load (module.js:343:32) 
2016-07-31T23:12:37.522135+00:00 app[web.1]:  at Object.Module._extensions..node (module.js:434:18) 
2016-07-31T23:12:37.522136+00:00 app[web.1]:  at Function.Module._load (module.js:300:12) 
2016-07-31T23:12:37.522137+00:00 app[web.1]:  at Module.require (module.js:353:17) 
2016-07-31T23:12:37.522138+00:00 app[web.1]:  at require (internal/module.js:12:17) 
2016-07-31T23:12:37.522139+00:00 app[web.1]:  at Object.<anonymous> (/app/server/node_modules/bcrypt/bcrypt.js:3:35) 
2016-07-31T23:12:37.522139+00:00 app[web.1]:  at bindings (/app/server/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44) 
2016-07-31T23:12:37.522140+00:00 app[web.1]:  at Module._compile (module.js:409:26) 
2016-07-31T23:12:37.522140+00:00 app[web.1]:  at Object.Module._extensions..js (module.js:416:10) 
2016-07-31T23:12:37.522141+00:00 app[web.1]:  at Module.load (module.js:343:32) 
2016-07-31T23:12:37.522142+00:00 app[web.1]:  at Module.require (module.js:353:17) 
2016-07-31T23:12:37.522142+00:00 app[web.1]:  at Function.Module._load (module.js:300:12) 
2016-07-31T23:12:37.522143+00:00 app[web.1]:  at Object.<anonymous> (/app/server/models/user.js:3:23) 
2016-07-31T23:12:37.522143+00:00 app[web.1]:  at require (internal/module.js:12:17) 
2016-07-31T23:12:37.522144+00:00 app[web.1]:  at Module._compile (module.js:409:26) 
2016-07-31T23:12:37.529768+00:00 app[web.1]: 
2016-07-31T23:12:37.535942+00:00 app[web.1]: npm ERR! Linux 3.13.0-91-generic 
2016-07-31T23:12:37.536334+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 
2016-07-31T23:12:37.536549+00:00 app[web.1]: npm ERR! node v4.4.7 
2016-07-31T23:12:37.536950+00:00 app[web.1]: npm ERR! npm v2.15.8 
2016-07-31T23:12:37.537269+00:00 app[web.1]: npm ERR! code ELIFECYCLE 
2016-07-31T23:12:37.537447+00:00 app[web.1]: npm ERR! ****@1.0.0 start: `cd server && npm install && node app.js` 
2016-07-31T23:12:37.537605+00:00 app[web.1]: npm ERR! Exit status 1 
2016-07-31T23:12:37.537772+00:00 app[web.1]: npm ERR! 
2016-07-31T23:12:37.537933+00:00 app[web.1]: npm ERR! Failed at the ****@1.0.0 start script 'cd server && npm install && node app.js'. 
2016-07-31T23:12:37.538132+00:00 app[web.1]: npm ERR! This is most likely a problem with the **** package, 
2016-07-31T23:12:37.538291+00:00 app[web.1]: npm ERR! not with npm itself. 
2016-07-31T23:12:37.538445+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 
2016-07-31T23:12:37.538601+00:00 app[web.1]: npm ERR!  cd server && npm install && node app.js 
2016-07-31T23:12:37.538768+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 
2016-07-31T23:12:37.538926+00:00 app[web.1]: npm ERR!  npm bugs **** 
2016-07-31T23:12:37.539078+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 
2016-07-31T23:12:37.539248+00:00 app[web.1]: npm ERR! 
2016-07-31T23:12:37.539399+00:00 app[web.1]: npm ERR!  npm owner ls **** 
2016-07-31T23:12:37.539536+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 
2016-07-31T23:12:37.542846+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 
2016-07-31T23:12:37.542943+00:00 app[web.1]: npm ERR!  /app/npm-debug.log 
2016-07-31T23:12:37.542671+00:00 app[web.1]: 
2016-07-31T23:12:37.613094+00:00 heroku[web.1]: Process exited with status 1 
2016-07-31T23:12:37.624890+00:00 heroku[web.1]: State changed from starting to crashed 
2016-07-31T23:13:53.875013+00:00 heroku[api]: Deploy 3be7c63 by ****@gmail.com 
2016-07-31T23:13:53.875094+00:00 heroku[api]: Release v20 created by ****@gmail.com 
2016-07-31T23:13:54.082054+00:00 heroku[slug-compiler]: Slug compilation started 
2016-07-31T23:13:54.082063+00:00 heroku[slug-compiler]: Slug compilation finished 
2016-07-31T23:13:54.206719+00:00 heroku[web.1]: State changed from crashed to starting 
2016-07-31T23:13:55.623943+00:00 heroku[web.1]: Starting process with command `npm start` 
2016-07-31T23:13:57.804242+00:00 app[web.1]: 
2016-07-31T23:13:57.804261+00:00 app[web.1]: > ****@1.0.0 start /app 
2016-07-31T23:13:57.804262+00:00 app[web.1]: > cd server && node app.js 
2016-07-31T23:13:57.804263+00:00 app[web.1]: 
2016-07-31T23:13:58.379535+00:00 app[web.1]:   throw e 
2016-07-31T23:13:58.379536+00:00 app[web.1]:  ^
2016-07-31T23:13:58.379520+00:00 app[web.1]: /app/server/node_modules/bcrypt/node_modules/bindings/bindings.js:83 
2016-07-31T23:13:58.379542+00:00 app[web.1]: Error: /app/server/node_modules/bcrypt/build/Release/bcrypt_lib.node: invalid ELF header 
2016-07-31T23:13:58.379544+00:00 app[web.1]:  at Object.Module._extensions..node (module.js:434:18) 
2016-07-31T23:13:58.379545+00:00 app[web.1]:  at Module.load (module.js:343:32) 
2016-07-31T23:13:58.379537+00:00 app[web.1]: 
2016-07-31T23:13:58.379543+00:00 app[web.1]:  at Error (native) 
2016-07-31T23:13:58.379547+00:00 app[web.1]:  at bindings (/app/server/node_modules/bcrypt/node_modules/bindings/bindings.js:76:44) 
2016-07-31T23:13:58.379545+00:00 app[web.1]:  at Function.Module._load (module.js:300:12) 
2016-07-31T23:13:58.379548+00:00 app[web.1]:  at Object.<anonymous> (/app/server/node_modules/bcrypt/bcrypt.js:3:35) 
2016-07-31T23:13:58.379546+00:00 app[web.1]:  at Module.require (module.js:353:17) 
2016-07-31T23:13:58.379546+00:00 app[web.1]:  at require (internal/module.js:12:17) 
2016-07-31T23:13:58.379549+00:00 app[web.1]:  at Object.Module._extensions..js (module.js:416:10) 
2016-07-31T23:13:58.379548+00:00 app[web.1]:  at Module._compile (module.js:409:26) 
2016-07-31T23:13:58.379550+00:00 app[web.1]:  at Function.Module._load (module.js:300:12) 
2016-07-31T23:13:58.379549+00:00 app[web.1]:  at Module.load (module.js:343:32) 
2016-07-31T23:13:58.379551+00:00 app[web.1]:  at Module.require (module.js:353:17) 
2016-07-31T23:13:58.379551+00:00 app[web.1]:  at require (internal/module.js:12:17) 
2016-07-31T23:13:58.387711+00:00 app[web.1]: 
2016-07-31T23:13:58.393911+00:00 app[web.1]: npm ERR! Linux 3.13.0-91-generic 
2016-07-31T23:13:58.394517+00:00 app[web.1]: npm ERR! node v4.4.7 
2016-07-31T23:13:58.379552+00:00 app[web.1]:  at Object.<anonymous> (/app/server/models/user.js:3:23) 
2016-07-31T23:13:58.379552+00:00 app[web.1]:  at Module._compile (module.js:409:26) 
2016-07-31T23:13:58.394260+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start" 
2016-07-31T23:13:58.395240+00:00 app[web.1]: npm ERR! code ELIFECYCLE 
2016-07-31T23:13:58.395014+00:00 app[web.1]: npm ERR! npm v2.15.8 
2016-07-31T23:13:58.395422+00:00 app[web.1]: npm ERR! ****@1.0.0 start: `cd server && node app.js` 
2016-07-31T23:13:58.396100+00:00 app[web.1]: npm ERR! This is most likely a problem with the **** package, 
2016-07-31T23:13:58.396258+00:00 app[web.1]: npm ERR! not with npm itself. 
2016-07-31T23:13:58.396614+00:00 app[web.1]: npm ERR!  cd server && node app.js 
2016-07-31T23:13:58.395590+00:00 app[web.1]: npm ERR! Exit status 1 
2016-07-31T23:13:58.395926+00:00 app[web.1]: npm ERR! Failed at the ****@1.0.0 start script 'cd server && node app.js'. 
2016-07-31T23:13:58.395759+00:00 app[web.1]: npm ERR! 
2016-07-31T23:13:58.396416+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system: 
2016-07-31T23:13:58.396937+00:00 app[web.1]: npm ERR!  npm bugs **** 
2016-07-31T23:13:58.396770+00:00 app[web.1]: npm ERR! You can get information on how to open an issue for this project with: 
2016-07-31T23:13:58.397098+00:00 app[web.1]: npm ERR! Or if that isn't available, you can get their info via: 
2016-07-31T23:13:58.400797+00:00 app[web.1]: 
2016-07-31T23:13:58.401032+00:00 app[web.1]: npm ERR! Please include the following file with any support request: 
2016-07-31T23:13:58.397260+00:00 app[web.1]: npm ERR! 
2016-07-31T23:13:58.397418+00:00 app[web.1]: npm ERR!  npm owner ls **** 
2016-07-31T23:13:58.397584+00:00 app[web.1]: npm ERR! There is likely additional logging output above. 
2016-07-31T23:13:58.401189+00:00 app[web.1]: npm ERR!  /app/npm-debug.log 
2016-07-31T23:13:58.456892+00:00 heroku[web.1]: Process exited with status 1 
2016-07-31T23:13:58.447070+00:00 heroku[web.1]: State changed from starting to crashed 

回答

0

已解決。原來是一個與bcrypt相關的問題。通過.gitignore我的node_modules並在heroku服務器端安裝依賴關係,現在一切正常。