it doesn't work on xxx.js or remote url,though xxx.json is ok
does anyone have the same problem as mine?
my Node.js:v18.19.0
this is a .js file in my work folder.
module.exports = () => {
const data = { users: [] };
// Create 1000 users
for (let i = 0; i < 1000; i++) {
data.users.push({ id: i, name: `user${i}` });
}
return data;
};
i tested these codes which copied on https://github.com/typicode/json-server/tree/v0
but something wrong
(base) PS T:\router> json-server --version
1.0.0-alpha.23
(base) PS T:\router> json-server http://jsonplaceholder.typicode.com/db
File http://jsonplaceholder.typicode.com/db not found
(base) PS T:\router> json-server --watch db.js
--watch/-w can be omitted, JSON Server 1+ watches for file changes by default
undefined:1
module.exports = () => {
^
SyntaxError: Unexpected token m in JSON at position 0
at JSONFile.parse (<anonymous>)
at JSONFile.read (file:///T:/myDev/env/nvm1.1.10/v18.19.0/node_modules/json-server/node_modules/lowdb/lib/adapters/node/DataFile.js:17:31)
at async Observer.read (file:///T:/myDev/env/nvm1.1.10/v18.19.0/node_modules/json-server/lib/observer.js:21:22)
at async Low.read (file:///T:/myDev/env/nvm1.1.10/v18.19.0/node_modules/json-server/node_modules/lowdb/lib/core/Low.js:16:22)
at async file:///T:/myDev/env/nvm1.1.10/v18.19.0/node_modules/json-server/lib/bin.js:114:1
Node.js v18.19.0
it doesn't work on xxx.js or remote url,though xxx.json is ok
does anyone have the same problem as mine?
my Node.js:v18.19.0
this is a .js file in my work folder.
i tested these codes which copied on
https://github.com/typicode/json-server/tree/v0
but something wrong