Cannot find module 'json-server'
See original GitHub issueI’m following the guide in README.md and I encountered error
Error: Cannot find module 'json-server' at Function.Module._resolveFilename (module.js:440:15) at Function.Module._load (module.js:388:25) at Module.require (module.js:468:17) at require (internal/module.js:20:19) at Object.<anonymous> (/Users/amycheong/Desktop/remote-json-server/dev/server.js:1:80) at Module._compile (module.js:541:32) at Object.Module._extensions..js (module.js:550:10) at Module.load (module.js:458:32) at tryModuleLoad (module.js:417:12) at Function.Module._load (module.js:409:3)'
when I node server.js
I have installed json-server globally.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:10 (5 by maintainers)
Top Results From Across the Web
How do I resolve "Cannot find module" error using Node.js?
This error can be encountered if you are require ing a module that has a missing or incorrect main ...
Read more >json-server - npm
Start using json-server in your project by running `npm i json-server`. There are 295 other projects in the npm registry using json-server.
Read more >json-server: command not found error [Solved] | bobbyhadz
Use npx to solve the error "json-server: command not found", e.g. npx json-server --watch db. · Look at the PATH environment variable on...
Read more >JSON Server (json-server) - DigitalOcean
You should have NPM installed on your machine. If not, then refer this post to install NPM. Below shows the one liner command...
Read more >Solved: "Cannot find module 'x.json'" TypeScript Error
Find out why this TypeScript error happens and how to fix it ... This happens because TypeScript does not support resolving JSON files...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
mmm … ok, try to install
json-serverlocally (not globally)npm init -ynpm install json-server --save-dev–
You also could try:
npm link json-servernode server.js–
aside from that, I highly recommend you to change your global node_modules directory by setting an Environment variable
NODE_PATHto/usr/lib/node_modulesexport NODE_PATH=/usr/lib/node_modulesand then try to reinstall json-server (
npm uninstall -g json-server && npm install -g json-server)I am assuming that you are missing a very very very simple and obvious step with I can’t guess, so I’ll write down the steps (sorry if it is super obvious for you) but just to make sure that we are in the same line.
fake-server)server.jsfilenpm install -g json-servernode server.jsif you did the above and it is still not running, from the same directory that
server.jsfile exist, runwhich json-serverand share the result of this command with us here.