npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Having Issues With NPM Json and prasing In Electron

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.


On what file I’m sorry I’ve been having some issues, Could you clarify


Hey guys,
I am setting up a small NPM application however I was having issues with this in the console:

$ npm start
npm ERR! file C:\Users\Jolly\Desktop\ZeduHow app\package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token } in JSON at position 182 while parsing near '...art": "electron .",
npm ERR! JSON.parse }
npm ERR! JSON.parse   "author": "Team ...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Jolly\AppData\Roaming\npm-cache\_logs\2019-03-03T00_41_01_463Z-debug.log

Thanks, Jolly


This is what I built it on still having the same issues


It says command not found


First issue, syntax error when you call npm start. Can you share your package.json?


You have got a syntax error in your package.json file, again. On a different line this time.

How are you creating the package.json?

The Electron tutorial I found covers creating a package.json, and it is quite a small file so you can compare with yours: https://electronjs.org/docs/tutorial/first-app#writing-your-first-electron-app


  1. You likely have a syntax error in your package.json. You can compare with the Electron Writing Your First Electron App and npm docs for Specifics of npm’s package.json handling, but an easy way of finding ordinary syntax errors is using an editor that understands json.

  2. command not found

Have you installed electron?
https://electronjs.org/docs/tutorial/first-app#installing-electron


Alright awesome thanks


I over came this error and got into a other error:

App threw an error during load
SyntaxError: Identifier 'app' has already been declared
    at Object.<anonymous> (C:\Users\Eric Lassard\Desktop\ZeduHow_Tech\Desktop_App_Beta\main.js:62:3)
    at Module._compile (internal/modules/cjs/loader.js:693:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:704:10)
    at Module.load (internal/modules/cjs/loader.js:602:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:541:12)
    at Function.Module._load (internal/modules/cjs/loader.js:533:3)
    at loadApplicationPackage (C:\Users\Eric Lassard\Desktop\ZeduHow_Tech\Desktop_App_Beta\node_modules\electron\dist\resources\default_app.asar\main.js:119:12)
    at Object.<anonymous> (C:\Users\Eric Lassard\Desktop\ZeduHow_Tech\Desktop_App_Beta\node_modules\electron\dist\resources\default_app.asar\main.js:164:5)
    at Object.<anonymous> (C:\Users\Eric Lassard\Desktop\ZeduHow_Tech\Desktop_App_Beta\node_modules\electron\dist\resources\default_app.asar\main.js:204:3)
    at Module._compile (internal/modules/cjs/loader.js:693:30)

Is this still npm or is npm working and this is just my end of not writing my code correctly?


Sure I’ll throw the whole project up on github!


Hey John are you on discord or skype?


That looks like a syntax error in your package.json. Do you see the same error when you try:

npm run


Yes, I do however still having the same issue


Here it is: https://drive.google.com/drive/folders/1U243A3w-HcNfMyrj9IfxmFA4Bks1JmK4?usp=sharing


That looks like a problem in your main.js file. Yes, you are past package setup problems (npm) and onto code problems.

Some progress! Good luck from there.


Here is the new issue:

I created a complete new project and this is what is happening:

Eric Lassard@LAPTOP-3D0I846T MINGW64 ~/Desktop/ZeduHow_Tech/Desktop_App_Beta
$ npm install --save-dev electron
npm ERR! file C:\Users\Eric Lassard\Desktop\ZeduHow_Tech\Desktop_App_Beta\package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 165 while parsing '{
npm ERR! JSON.parse   "name": "zeduhow-app",
npm ERR! JSON.parse   "version": '
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Eric Lassard\AppData\Roaming\npm-cache\_logs\2019-03-05T04_35_20_862Z-debug.log

Thanks, Eric!


Found it, however, I am so sad to say that it is running the same error. Yuuuupo


I see however sadly I did follow the article


Changing the middle part to this below should solve the syntax error:

From:

  "scripts": {
    "start": "electron .",
}

To:

  "scripts": {
    "start": "electron ."
  },


No. Forum only. :hear_no_evil: :headphones: