Open Drachenfels opened 7 months ago
I have a similar error. Today I was trying to use json-server-auth, but end up with the error message.
Let me put the error first:
node:internal/modules/cjs/loader:1147
throw err;
^
Error: Cannot find module 'json-server'
Require stack:
- /usr/local/lib/node_modules/json-server-auth/dist/guards.js
- /usr/local/lib/node_modules/json-server-auth/dist/bin.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
at Module._load (node:internal/modules/cjs/loader:985:27)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/usr/local/lib/node_modules/json-server-auth/dist/guards.js:6:20)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/json-server-auth/dist/guards.js',
'/usr/local/lib/node_modules/json-server-auth/dist/bin.js'
]
}
Node.js v20.11.0
In my project, I use npm init
to create package.json
then use npm install -D json-server json-server-auth
to create node_modules
, package-lock.json
and then create db.json
file in my project
and use sudo npm install -g json-server-auth
,
then I finally use json-server-auth db.json
, but it doesn't start the server,
showed the Error: Cannot find module 'json-server'
package.json code
{
"name": "vue-hangout-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"json-server": "^1.0.0-alpha.22"
},
"dependencies": {
"express": "^4.18.2",
"json-server-auth": "^2.1.0"
}
}
I'm sure I install the latest version json-server and json-server-auth,
How can I make sure it finds module 'json-server'?
Looks like there is an issue in alpha version.
I can able to run normally using json-server@^0.17.3
Can confirm, it works on 0.17.4 but not on the latest release
This issue exists for me also.
Да, проблема в версии. npm i json-server@0.17.4 - решение
Confirm, doesn't work with version 1.0.0-alpha.23
Correct. This issue is existing with the latest version. It does not there in "0.16.3".
Any ETA on fixing? It's great to have paging and sorting already done by json-server
Any ETA on fixing? It's great to have paging and sorting already done by json-server
Tool feels to be if not abandoned then not under active development. So probably would need forking or something.
doesn't work with version "^1.0.0-alpha.23", I use "0.17.4" version is OK
Looks like there is an issue in alpha version.
I can able to run normally using json-server@^0.17.3
just spent 3 hours debugging this just to find out it was the version issue. Thank you so much for the answer
It happened with me also, it works properly with json-server@^0.17.4 and before versions but not on alpha versions. So i would recommend to use json-server@^0.17.4 versions
I'm also having exactly the same Issue , Should we just Downgrade our json-server-auth ? whould it be enough to solve the problem????
What about my json-server-auth ? which version of it should i install ??
Yes downgrade and use json-server@^0.17.4 versions. It will work absolutely without any problem with node
Thanks a lot @prasannabiswas , I did it and the problem is solved 😊
the solution is install the version "json-server": "^0.17.3", using pnpm i json-server@^0.17.3 or npm
Confirming, it doesn't work with v^1.0.0-beta.1 as well.
Confirming, it doesn't work with v^1.0.0-beta.2 as well.
I am trying to follow one older tutorial: https://www.journeytoawebapp.com/posts/local-mock-server-with-node
Fresh repository I copy-pasted the code:
I did
npm install json-server
and I have this:But when I try to run the code with
node server.js
:My root:
My node_modules:
My NODE_PATH is empty (in case it's relevant):