node.js heroku由于缺less依赖关系,Ghost无法启动:无法find模块
我一直在这工作几个小时,没有运气。 我刚刚下载了Ghost 0.7.0
到我的本地机器上,开箱即用, npm start
工作完美。 我尝试安装我的第一个包时遇到错误。 我正在安装的软件包是ghost-s3-storage 。 但是,在部署到heroku时,所有包都返回类似的错误。
这是我的步骤…
$ npm start -> works $ npm install --save ghost-s3-storage $ npm start -> still works
所以,现在我的package.json
包含准确的依赖关系,所以Heroku应该正确部署,但它不。 这似乎是由Heroku运行的三个命令引起的(根据他们的指南 )。 当我在本地运行命令时,我可以复制错误。
$ rm -rf node_modules $ npm install --quiet --production $ npm start -> ERROR: Ghost is unable to start due to missing dependencies: Cannot find module 'ghost-s3-storage'
在这一点上,我的package.json
看起来是正确的。
package.json "dependencies": { ..., "ghost-s3-storage": "^0.2.2", ..., }
但是, node_modules
缺lessghost-s3-storage
。
$ npm ls -> UNMET DEPENDENCY ghost-s3-storage@^0.2.2 -> npm ERR! missing: ghost-s3-storage@^0.2.2, required by ghost@0.7.0
所以我很难过 Heroku是愚蠢的,或者是node.js,或者我。 请帮忙。
我有完全相同的问题,我用npm shrinkwrap
解决了这个问题。
npm shrinkwrap
locking包依赖关系( https://docs.npmjs.com/cli/shrinkwrap )
另请参阅此build议: https : //docs.npmjs.com/misc/faq#should-i-check-my-node-modules-folder-into-git
我也有同样的问题,可以报告运行npm shrinkwrap
,提交和部署到Heroku解决了这个问题。