$ npx json-server --version
1.0.0-alpha.23
$ node -v
v20.12.0
$ ls
generate.js node_modules package.json package-lock.json public README.md src
I've been attempting to launch a React project locally from a GitHub repository. Despite installing most dependencies, I'm facing difficulties executing a .js
file using json-server
.
The specific file I'm trying to load with json-server
is located here:
https://github.com/brucevanhorn2/reactstrap-course/blob/master/generate.js
This is the error message appearing in my VS Code terminal after running the command:
npx json-server generate.js
undefined:1
module.exports = function(){
^
SyntaxError: Unexpected token 'm', "module.exp"... is not valid JSON
at JSONFile.parse (<anonymous>)
at JSONFile.read (file:///home/niveus/PRAKASH/VS_CODE/flying_cars/node_modules/lowdb/lib/adapters/node/DataFile.js:17:31)
at async Observer.read (file:///home/niveus/PRAKASH/VS_CODE/flying_cars/node_modules/json-server/lib/observer.js:21:22)
at async Low.read (file:///home/niveus/PRAKASH/VS_CODE/flying_cars/node_modules/lowdb/lib/core/Low.js:16:22)
at async file:///home/niveus/PRAKASH/VS_CODE/flying_cars/node_modules/json-server/lib/bin.js:114:1
Node.js v20.12.0
I've attempted various export methods like
export default () => {}
in the generate.js file, yet no success.
Any ideas on what might be causing this issue?