简体   繁体   中英

Heroku error module not found 'json-server'

I want to deploy my server on Heroku, but on Heroku build it says this:

在此处输入图片说明

The app works fine locally, but somehow it crashes on the Heroku server.

This is the file structure在此处输入图片说明

This is the code for server.js

const jsonServer = require('json-server');
const server = jsonServer.create();
const router = jsonServer.router('data.json');
const port = process.env.PORT || 4000;

server.use(router);
server.listen(port);

This is package.json

{
  "name": "server",
  "version": "1.0.0",
  "description": "json-server",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "npm install && node server.js"
  },
  "author": "japsuchiha",
  "license": "ISC",
  "dependencies": {
    "core-util-is": "^1.0.2"
  },
  "devDependencies": {
    "json-server": "^0.15.1"
  }
}

纯猜测,但我不认为 heroku 正在安装 json-server,因为它列在 devDependencies 下

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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