[英]Heroku node_modules not found
I have a REST API built using Node.js and Express.js.我有一个使用 Node.js 和 Express.js 构建的 REST API。 The api works when running locally (tested via postman) and also works with heroku local web
.该 api 在本地运行时有效(通过邮递员测试),也适用于heroku local web
。
The problem comes when I deploy it to Heroku.当我将它部署到 Heroku 时,问题就来了。 As far I know, it doesnt find node_modules
folder.据我所知,它没有找到node_modules
文件夹。 here is the error when viewing Heroku logs.这是查看 Heroku 日志时的错误。
2018-08-05T23:06:22.543693+00:00 app[web.1]: npm ERR! Failed at the rest-api@0.0.1 start script.
2018-08-05T23:06:22.543859+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2018-08-05T23:06:22.551894+00:00 app[web.1]:
2018-08-05T23:06:22.552047+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2018-08-05T23:06:22.552153+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2018-08-05T23_06_22_545Z-debug.log
2018-08-05T23:06:22.633382+00:00 heroku[web.1]: Process exited with status 1
2018-08-05T23:06:22.844536+00:00 heroku[web.1]: State changed from starting to crashed
I logged to Heroku bash using heroku run bash
and see all my files including node_modules
is there.我使用heroku run bash
登录到 Heroku bash 并看到我的所有文件,包括node_modules
都在那里。 Tried running running yarn dev
in the bash (my start script) here is what i get尝试在 bash 中运行yarn dev
(我的启动脚本)这是我得到的
~ $ yarn dev
yarn run v1.9.4
$ nps dev
/bin/sh: 1: nps: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Here is my package.json
file Package.json Here is my package-scripts.js
file package-scripts.js这是我的package.json
文件Package.json这是我的package-scripts.js
文件package-scripts.js
Any help would be greatly appreciated, I literally tried every stackoverflow suggestion but still no luck任何帮助将不胜感激,我确实尝试了每个 stackoverflow 建议,但仍然没有运气
在Heroku的配置变量中设置NODE_MODULES_CACHE=false
Check if your package.json file has the dependencies added. 检查您的package.json文件是否添加了依赖项。 I faced the same problem cuz I didnt have the dependencies. 我遇到了同样的问题,因为我没有依赖项。
Set heroku config:set NPM_CONFIG_PRODUCTION=false
and try.设置heroku config:set NPM_CONFIG_PRODUCTION=false
并尝试。 Heroku will strip out the packages declared under devDependencies before deploying the application. Heroku 将在部署应用程序之前删除在 devDependencies 下声明的包。 nps module under devDependencies will not be available. devDependencies 下的 nps 模块将不可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.