[英]i am developing an app with node js , it works perfectly locally but crashes anytime i try to upload it to heroku,it says cat find dotenv
i am developing an app with node js , it works perfectly locally but crashes anytime i try to upload it to heroku,it says Error: Cannot find module 'dotenv.i have installed it serval times and also updated my package but the problem continues, this is my package.json { "name": "myapp", "description": "a really cool app", "version": "1.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "engines": { "node": "10.16.3", "npm": "6.13.4" }, "dependencies": { "@mapbox/mapbox-sdk": "^0.9.0", "body-parser": "^1.19.0", "cookie-parser": "~1.4.4", "debug": "~4.1.1", "ejs": "~3.0.1", "ejs-mate": "^3.0.0", "express": "^4.17.1", "express-session": "^1.17.0", "faker": "^4.1.0", "http-errors": "~1.7.3", "method-override": "^3.0.0", "mongoose": "^5.8.1", "mongoose-paginate": "^5.0.3", "morgan": "~1.9.1", "passport": "^0.4.1", "passport-local": "^1.0.0", "passport-local-mongoose": "^5.0.1", "serve-favicon": "^2.5.0" }, "devDependencies": { "dotenv": "^8.2.0", "locus": "^2.0.4" } }
this is m我正在使用 node js 开发一个应用程序,它在本地运行良好,但在我尝试将其上传到 heroku 时崩溃,它说错误:找不到模块 'dotenv.i 已经安装了它多次并更新了我的包,但问题仍然存在,这是我的 package.json
{ "name": "myapp", "description": "a really cool app", "version": "1.0.0", "private": true, "scripts": { "start": "node ./bin/www" }, "engines": { "node": "10.16.3", "npm": "6.13.4" }, "dependencies": { "@mapbox/mapbox-sdk": "^0.9.0", "body-parser": "^1.19.0", "cookie-parser": "~1.4.4", "debug": "~4.1.1", "ejs": "~3.0.1", "ejs-mate": "^3.0.0", "express": "^4.17.1", "express-session": "^1.17.0", "faker": "^4.1.0", "http-errors": "~1.7.3", "method-override": "^3.0.0", "mongoose": "^5.8.1", "mongoose-paginate": "^5.0.3", "morgan": "~1.9.1", "passport": "^0.4.1", "passport-local": "^1.0.0", "passport-local-mongoose": "^5.0.1", "serve-favicon": "^2.5.0" }, "devDependencies": { "dotenv": "^8.2.0", "locus": "^2.0.4" } }
这是 m y Procfile web: node app.js
this is my git ignore file /node_modules
.DS_Store
/*.env
y Procfile
web: node app.js
这是我的 git 忽略文件/node_modules
.DS_Store
/*.env
Try movin dotenv
from 'devDependencies' to 'dependencies'尝试从 'devDependencies' 到 'dependencies' 移动
dotenv
Anything that is needed to actually run your app (lets call it "in production"), should be in 'dependencies'.实际运行您的应用程序所需的任何内容(我们称之为“生产中”)都应该在“依赖项”中。
Anything that you may need while eg testing can be installed to 'devDependencies'您在测试时可能需要的任何东西都可以安装到“devDependencies”
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.