我在node.js上安装了sanitize-html npm库并表达了应用程序。我正在使用Cloud9 IDE,它允许预览您的网站。 Sanitize-html在预览中完成了它的工作并完美运行,但当我尝试使用heroku将我的应用程序部署到Web时,我收到了一个应用程序错误。我知道错误是由于sanitize-html,因为当我删除它并部署我的应用程序时,一切正常。这是我的heroku日志:
2016-02-22T16:35:13.344238+00:00 heroku[web.1]: State changed from crashed to starting
2016-02-22T16:35:14.684861+00:00 heroku[web.1]: Starting process with command `npm start`
2016-02-22T16:35:06.369072+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=sharecookie.herokuapp.com request_id=b37b7b05-5b82-4668-80fb-5714a0ddbc61 fwd="207.74.9.2" dyno= connect= service= status=503 bytes=
2016-02-22T16:35:15.916200+00:00 app[web.1]:
2016-02-22T16:35:15.916220+00:00 app[web.1]: > node bin/www
2016-02-22T16:35:15.916221+00:00 app[web.1]:
2016-02-22T16:35:16.489614+00:00 app[web.1]: npm ERR! Linux 3.13.0-77-generic
2016-02-22T16:35:16.472662+00:00 app[web.1]: module.js:341
2016-02-22T16:35:16.472665+00:00 app[web.1]: throw err;
2016-02-22T16:35:16.489936+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2016-02-22T16:35:16.490118+00:00 app[web.1]: npm ERR! node v5.6.0
2016-02-22T16:35:16.472666+00:00 app[web.1]: ^
2016-02-22T16:35:16.472667+00:00 app[web.1]:
2016-02-22T16:35:16.472668+00:00 app[web.1]: Error: Cannot find module 'sanitize-html'
2016-02-22T16:35:16.472670+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-02-22T16:35:16.472670+00:00 app[web.1]: at require (internal/module.js:16:19)
2016-02-22T16:35:16.472671+00:00 app[web.1]: at Object.<anonymous> (/app/routes/index.js:11:20)
2016-02-22T16:35:16.472671+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-02-22T16:35:16.472672+00:00 app[web.1]: at Object.Module._extensions..js (module.js:422:10)
2016-02-22T16:35:16.472676+00:00 app[web.1]: at Object.<anonymous> (/app/app.js:14:14)
2016-02-22T16:35:16.472677+00:00 app[web.1]: at Module._compile (module.js:413:34)
Blah等等,它说找不到'sanitize-html'模块,即使它安装在node_modules中,并在我的index.js中引用为var sanitizeHtml = require('sanitize-html');
这真的很令人沮丧。任何帮助表示赞赏:)
答案 0 :(得分:0)
我找到了回答浏览其他问题的答案。我需要使用git add -A --force
来完全重新添加我的所有模块,这是有效的。有点奇怪