Is my JSON file being formatted properly? - javascript

package.json:
{
"name": "password-generator",
"productName": "Password Generator",
"version": "1.0.0",
"description": "Password generator desktop app",
"main": "main.js",
"scripts": {
"start": "electron ."
"build-installer": "electron-builder"
},
"build": {
"appId": "password-generator",
},
"win": {
"target": ["nsis"],
"icon": "/icon.png",
},
"nsis": {
"installerIcon": "/icon.png",
"uninstallerIcon": "/icon.png",
"uninstallDisplayName": "Password Generator",
"oneClick": false,
"allowToChangeInstallationDirectory": true,
},
"author": "JipBit",
"license": "ISC",
"devDependencies": {
"electron-forge": "^5.2.4",
},
"dependencies": {
"electron-builder": "^22.7.0",
},
}
Error:
npm ERR! code EJSONPARSE
npm ERR! file C:\Users\mel\Desktop\Password Generator\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 212 while parsing '{
npm ERR! JSON.parse "name": "password-generator",
npm ERR! JSON.parse "pro'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
Information: When attempting to run npm start and npm run build-installer, I get this error about my package.json file. I got this error after adding on to my package.json while setting up to run the build-installer to make my electron app an executable.
Edit of new error:
'electron' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! password-generator#1.0.0 start: `electron .`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the password-generator#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Initially looking at it, you need a ',' on line 8 after:
"start": "electron ."
EDIT:
Try this, there are just a few misplaced commas:
{
"name": "password-generator",
"productName": "Password Generator",
"version": "1.0.0",
"description": "Password generator desktop app",
"main": "main.js",
"scripts": {
"start": "electron .",
"build-installer": "electron-builder"
},
"build": {
"appId": "password-generator"
},
"win": {
"target": ["nsis"],
"icon": "/icon.png"
},
"nsis": {
"installerIcon": "/icon.png",
"uninstallerIcon": "/icon.png",
"uninstallDisplayName": "Password Generator",
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"author": "JipBit",
"license": "ISC",
"devDependencies": {
"electron-forge": "^5.2.4"
},
"dependencies": {
"electron-builder": "^22.7.0"
}
}

Hi you have many coma mistakes.
Use this page to correct your JSON :
https://codebeautify.org/jsonviewer
Here is your JSON corrected :
{
"name": "password-generator",
"productName": "Password Generator",
"version": "1.0.0",
"description": "Password generator desktop app",
"main": "main.js",
"scripts": {
"start": "electron .",
"build-installer": "electron-builder"
},
"build": {
"appId": "password-generator"
},
"win": {
"target": ["nsis"],
"icon": "/icon.png"
},
"nsis": {
"installerIcon": "/icon.png",
"uninstallerIcon": "/icon.png",
"uninstallDisplayName": "Password Generator",
"oneClick": false,
"allowToChangeInstallationDirectory": true
},
"author": "JipBit",
"license": "ISC",
"devDependencies": {
"electron-forge": "^5.2.4"
},
"dependencies": {
"electron-builder": "^22.7.0"
}
}

Related

jsdoc error ENOENT: no such file or directory, open './readme/readme.md'

I have already installed jsdoc with npm i -D jsdoc command and created jsdoc.json file. In package.json file there is script called doc and after doing npm run doc jsdoc throws an error Error: ENOENT: no such file or directory, open './readme/readme.md'
package.json
{
"name": "alphabetdb",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "node index.js",
"doc": "jsdoc -c jsdoc.json"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"jsdoc": "^3.6.10"
}
}
jsdoc.json
{
"source": {
"include": ["src"],
"includePattern": ".js$",
"excludePattern": "(node_modules/|docs)"
},
"plugins": ["plugins/markdown"],
"templates": {
"cleverLinks": true,
"monospaceLinks": true
},
"opts": {
"recurse": true,
"destination": "./docs/",
"template": "./custom-template",
"tutorials": "./tutorials",
"readme": "./readme/readme.md"
}
}
file tree
node_modules/
src/
fileSystem.js
index.js
jsdoc.js
package-lock.json
package.json
You have to remove the "readme": "./readme/readme.md". Seems like this is an outdated parameter, as it is also not mentioned in the docs.

NODE & ELECTRON No valid versions available for electron-navigation

i tried to build a open source "Browser that allow flash player"
My problem is, when i use "npm install"
it's return me this error:
npm ERR! code ENOVERSIONS
npm ERR! No valid versions available for electron-navigation
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\rstei\AppData\Roaming\npm-cache\_logs\2021-08-18T13_30_37_799Z-debug.log
My package.json:
{
"name": "Misaki",
"productName": "Flash Browser",
"description": "Electron Browser For Games",
"homepage": "https://www.flashbrw.com",
"author": "Misaki",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "electron .",
"publish": "electron-builder --win -p always",
"build": "electron-builder --win"
},
"license": "ISC",
"devDependencies": {
"electron": "^9.0.5",
"electron-builder": "22.9.1"
},
"dependencies": {
"electron-navigation": "^1.5.8",
"electron-updater": "4.3.5"
},
"build": {
"appId": "com.flashbrw.app",
"extraResources": [
"./plugins/**"
],
"directories": {
"buildResources": "resources",
"output": "release"
},
"publish": [
{
"provider": "github",
"owner": "asteroid-dev",
"repo": "FlashBrowser"
}
],
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64",
"ia32"
]
}
]
},
"nsis": {
"installerIcon": "icon.ico",
"uninstallerIcon": "icon.ico",
"uninstallDisplayName": "Flash Browser",
"oneClick": true,
"perMachine": false,
"artifactName": "FlashBrowser.${ext}"
}
}
}
if you want see the open source: https://github.com/asteroid-dev/FlashBrowser
Thanks in advance for someone can find a way for fix it !
Your project specifies a non-existent version of the electron-navigation module.
Your package.json calls for "electron-navigation": "^1.5.8". The version specifier, ^1.5.8, permits any version greater than or equal to 1.5.8 and below 2.0.0.
However, it appears the only available version of that package is version 6.6.6. You can confirm this from the command line:
$ npm show electron-navigation versions
6.6.6
The specifier ^1.5.8 does not accept 6.6.6.
I can only guess why your project is asking for such a precise but non-existent version. Change the specifier to ^6.6.6, and it should install fine.

How to fix "Npm ERR! JSON.parse Unexpected string in JSON at position 228.."

I am trying to start NPM after installing it but the start errors out.
I couldn't find syntactical errors in the 'package.json' file
I couldn't find the error log
I tried reinstalling
I tried clearing my cache
All without success
Here is my 'package.json' file:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite"
"test": "echo \"Error: no test specified\" && exit 1"
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url": "https://github.com/Master-Hippo/Front-
End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-
End_Web_UI_Frameworks_and_Tools#readme"
Here is the ERROR LOG in #bash:
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected string in JSON at position 228 while parsing
'{
npm ERR! JSON.parse "name": "git-test",
npm ERR! JSON.parse "version": "1.'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
And, although the message says an error log was created in a specific folder, none actually exists in said folder.
How can I resolve this issue?
Try validate your package.json with jsonlint
I guess that your file could be like this:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url ": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools#readme"
}
Your package.json should be valid json like this:
{
"name": "git-test",
"version": "1.0.0",
"description": "test json file",
"main": "index.js",
"dependencies": {},
"devDependencies": {
"lite-server": "^2.4.0"
},
"scripts": {
"start": "npm run lite",
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "lite-server"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools.git"
},
"author": "Master-Hippo",
"license": "ISC",
"bugs": {
"url": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools/issues"
},
"homepage": "https://github.com/Master-Hippo/Front-End_Web_UI_Frameworks_and_Tools#readme"
}
There were a few commas missing.

How resolve "Error: invalid reporter "html-cov"" in nodejs

package.json
{
"name": "learningmocha",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "mocha && mocha test --require blanket --reporter html-cov > coverage.html"
},
"author": "",
"license": "ISC",
"devDependencies": {
"blanket": "^1.2.3",
"chai": "^3.5.0",
"mocha": "^3.2.0"
},
"config": {
"blanket": {
"pattern": [ "index.js" ],
"data-cover-never": "node-module"
}
}
}
I am using Mocha for testing in nodejs. when i run npm test after adding html-cov in the test script of my package.json as show above then it give me error
"Error: invalid reporter "html-cov"
You can see more in this image
html-cov was dropped in 3.0.0 [1]
[1] https://github.com/mochajs/mocha/issues/2356

How do you run multiple grunt scripts.postinstall?

I'm trying to run multiple CLI commands from scripts.postinstall of grunt. I can't figure out how to get both to run. If I add the second command neither run. Separately they both work on postinstall and in the console.
I've tried wrapping them in an array:
"scripts": {
"postinstall": ["node_modules/.bin/bower install", "grunt setup"]
},
I tried separating them with a semi-colon:
"scripts": {
"postinstall": "node_modules/.bin/bower install; grunt setup"
},
I can't seem to find the solution on NPM Scripts
My gruntfile.js for these sections look like this:
mkdir: {
setup: {
options: {
create: [
'app/main/source/www', 'app/main/build', 'app/main/docs', 'app/main/tests',
'app/development',
'app/releases'
]
}
}
}
grunt.registerTask('setup', [
'mkdir:setup',
'bowercopy:wordpress'
]);
In case it helps here's a parred down version of my package.json that I snipped the above code examples, mostly to provide context.
{
"name": "webapp",
"version": "0.1.0",
"description": "A web app using bower and grunt",
"main": "gruntfile.js",
"scripts": {
"postinstall": "node_modules/.bin/bower install"
},
"repository": {
"type": "git",
"url": "someurl.com"
},
"keywords": [
"web", "app"
],
"author": {
"company": "somecompany",
"name": "somename",
"email": "email#me.com"
},
"license": "MIT",
"homepage": "https://someurl.com",
"bugs": {
"url": "someurl.com"
},
"devDependencies": {
"grunt": "^0.4.5",
"bower" : "~1.3.5",
etc
}
}
You can use && to run multiple commands in the npm scripts section
"scripts": {
"postinstall": "bower install && grunt setup"
},
You could try writing a Bash script that executes those two commands and run that instead.
post_install.sh:
#!/bin/bash
node_modules/.bin/bower install
grunt setup
package.json:
"scripts": {
"postinstall": "./post_install.sh"
},

Categories