Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npm ERR code EJSONPARSE - Failed to parse json [closed]

Tags:

json

node.js

So I was just about to setup this login form for my page using node.js I ran

npm init

and went trough the various steps to complete it. When I was all done with that, and the package.json file had been created I added these lines of code"

 dependencies": {
         "bcryptjs": "*",
         "body-parser": "*",
         "connect-flash": "*",
         "cookie-parser": "^1.4.1",
         "express": "*",
         "express-handlebars": "*",
         "express-messages": "*",
         "express-session": "*",
         "express-validator": "*",
         "mongodb": "*",
         "mongoose": "*",
         "passport": "*",
         "passport-http": "*",
         "passport-local": "*"   }

I now ran the command

npm install

But ended up getting these ERRORS

npm ERR! file /Users/albingroen/Desktop/newProject/package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token '\n' at 26:5
npm ERR!   }
npm ERR!     ^
npm ERR! File: /Users/albingroen/Desktop/newProject/package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/albingroen/.npm/_logs/2017-04-04T18_52_34_920Z-debug.log

I have tried following things:

  • Cleaning the node cache

  • Using different terminal

  • Updating node.js

  • Updating mongodb

  • Changing location of package.json

  • Running npm install without the added dependencies

  • Deleting the nodemodules mapp

I really don't know what to do anymore. Somebody got an idea?

like image 220
albingroen Avatar asked Mar 11 '26 16:03

albingroen


1 Answers

I had the same error. It is caused by wrong syntax within your package.json. I solved it by removing an unnecessary ',' at the end of my last dependency, but it can be different for everyone. Looking over the package.json syntax would be the best bet.

like image 106
vgro Avatar answered Mar 13 '26 09:03

vgro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!