Having Issues With NPM Json and prasing In Electron


(A Jolly Dev) #1

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


(John Gee) #2

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

npm run

(A Jolly Dev) #3

Yes, I do however still having the same issue


(A Jolly Dev) #4

It says command not found


(John Gee) #5
  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


(A Jolly Dev) #6

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


(John Gee) #7

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


(A Jolly Dev) #8

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


(A Jolly Dev) #9

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


(Lars Willighagen) #10

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

From:

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

To:

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

(A Jolly Dev) #11

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


(A Jolly Dev) #12

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


(A Jolly Dev) #13

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!


(John Gee) #14

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


(A Jolly Dev) #15

Hey John are you on discord or skype?


(John Gee) #16

No. Forum only. :hear_no_evil: :headphones:


(A Jolly Dev) #17

I see however sadly I did follow the article


(A Jolly Dev) #18

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?


(John Gee) #19

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.


(A Jolly Dev) #20

Alright awesome thanks