[SOLVED] Noob question on adding scripts to package.json

Hi everyone and merry xmas!

I just started with the tutorials to learn everything. When I try to add a script to the package.json as describe in one of the tutorials Im getting a problem. What am I doing wrong?

package.json including the script (see at the end):

{
  "name": "simple-nodejs",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "express": "^4.18.2",
    "moralis": "^2.10.3"
  }
}
"scripts": {
 "start": "node index.js"
},

The problem message Im getting is:
End of file expected.

Im sure there is an easy answer for it and sorry for the noob question. Thanks!!!

That text may need to be a valid jail file. Id that is all the file that maybe it is not a valid json file. It looks like it has , at the end instead of a }

Thanks for your reply. That doesnt seem to be the issue. I delete the , but nothing changed. BTW this is the Moralis tutorial Iā€™m trying to copy and learn from:

You needed to add the start script to the existing scripts object:

{
    "name": "simple-nodejs",
    "version": "1.0.0",
    "description": "",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1", 
      "start": "node index.js"
    },
    "author": "",
    "license": "ISC",
    "dependencies": {
      "express": "^4.18.2",
      "moralis": "^2.10.3"
    }
  }

You can read this for an intro to working with JSON.

1 Like

Amazing, thanks guys for the quick response! :blue_heart: