Japneet Singh
Japneet Singh

Reputation: 67

Heroku error module not found 'json-server'

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

enter image description here

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

This is the file structure enter image description here

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"
  }
}

Upvotes: 0

Views: 818

Answers (1)

greger breger
greger breger

Reputation: 108

Pure guess, but I don't think heroku is installing json-server since it's listed under devDependencies

Upvotes: 7

Related Questions