简体   繁体   English

Heroku:找不到模块“pg”?

[英]Heroku : Cannot find module 'pg'?

2021-03-19T16:05:15.937220+00:00 app[web.1]: Error: Cannot find module 'pg' 2021-03-19T16:05:15.937220+00:00 app[web.1]:错误:找不到模块“pg”

2021-03-19T16:05:15.937220+00:00 app[web.1]: Require stack: 2021-03-19T16:05:15.937220+00:00 应用程序 [web.1]:需要堆栈:

2021-03-19T16:05:15.937220+00:00 app[web.1]: - /app/models/db_schema.js 2021-03-19T16:05:15.937220+00:00 应用程序 [web.1]:-/app/models/db_schema.js

2021-03-19T16:05:15.937221+00:00 app[web.1]: - /app/controllers/event_controller.js 2021-03-19T16:05:15.937221+00:00 应用程序 [web.1]: - /app/controllers/event_controller.js

2021-03-19T16:05:15.937221+00:00 app[web.1]: - /app/router/event_routes.js 2021-03-19T16:05:15.937221+00:00 应用 [web.1]: - /app/router/event_routes.js

2021-03-19T16:05:15.937221+00:00 app[web.1]: - /app/app.js 2021-03-19T16:05:15.937221+00:00 应用 [web.1]: - /app/app.js

This is my package.json这是我的 package.json

{ {

"name": "backend", “名称”:“后端”,

"version": "1.0.0", “版本”:“1.0.0”,

"description": "", “描述”: ””,

"main": "app.js", “主”:“app.js”,

"engines": { “引擎”: {

"node": "v14.12.0",

"npm": "6.14.8"

}, },

"scripts": { “脚本”:{

"test": "echo \"Error: no test specified\" && exit 1",

"start": "node app.js",

"start:dev": "nodemon app.js",

"heroku-postbuild": "cd frontend && npm install && npm run build"

}, },

"repository": { “存储库”:{

"type": "git",

"url": "git+https://github.com/shivamsouravjha/shawn-the-sheep.git"

}, },

"author": "shivam", “作者”:“shivam”,

"license": "ISC", “许可证”:“ISC”,

"bugs": { “错误”:{

"url": "https://github.com/shivamsouravjha/shawn-the-sheep/issues"

}, },

"homepage": "https://github.com/shivamsouravjha/shawn-the-sheep#readme", “主页”:“https://github.com/shivamsouravjha/shawn-the-sheep#readme”,

"devDependencies": { “开发依赖”:{

"nodemon": "^2.0.7",


"pg": "^8.5.1",

"router": "^1.3.5"

}, },

"dependencies": { “依赖”:{

"cors": "^2.8.5",

"dotenv": "^8.2.0",

"express": "^4.17.1",

"express-validator": "^6.10.0"

} }

} }

So the file structure would be:所以文件结构是:

/app /应用程序

----app.js ----app.js

----node_modules/ ----node_modules/

It is also necessary to move pg from devDependencies into Dependencies and run npm run build.还需要将 pg 从 devDependencies 移动到 Dependencies 并运行 npm run build。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM