Nodejs Error EJSONPARSE ERROR - node.js

{
"name": "nodej",
"version": "1.0.0",
"description": "",
"main": "index.js.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"start":"node index"
},
"author": "",
"license": "ISC"
}
when i type npm start i get these errors:
C:\Users\User\Documents\nodejs\nodej>npm start
npm ERR! file C:\Users\User\Documents\nodejs\nodej\package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected string in JSON at position 166 while parsing '{
npm ERR! "name": "nodej",
npm ERR! "version": "1.0.0'
npm ERR! File: C:\Users\User\Documents\nodejs\nodej\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! 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! C:\Users\User\AppData\Roaming\npm-cache_logs\2017-12-
10T17_30_24_632Z-debug.log

You need to add a comma after the test script:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1", <-- COMMA HERE
"start":"node index"
},

{
"name": "nodej",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

Related

npm install throwing expected "0.15.7" but got "" on new vite project

I just created a new vite project and i am getting the following error when executing npm install.
node.js: 16.17.0
npm: 8.15.0
npm ERR! C:\xxx\GIT\NewTestProject\node_modules\esbuild\install.js:93
npm ERR! throw new Error(`Expected ${JSON.stringify("0.15.7")} but got ${JSON.stringify(stdout)}`);
npm ERR! C:\xxx\GIT\NewTestProject\node_modules\esbuild\install.js:93
npm ERR!
npm ERR! Error: Expected "0.15.7" but got ""
npm ERR! at validateBinaryVersion (C:\xxx\GIT\NewTestProject\node_modules\esbuild\install.js:93:11)
npm ERR! at C:\xxx\GIT\NewTestProject\node_modules\esbuild\install.js:240:5
package.json
{
"name": "newtestproject",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"vue": "^3.2.37"
},
"devDependencies": {
"#vitejs/plugin-vue": "^3.1.0",
"vite": "^3.1.0"
}
}
Running cmd as admin solved the issue.

Trying to run "npm run devStart" on mac

This is my package.json
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js",
"devStart": "nodemon index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.1",
"express": "^4.17.2",
"mysql": "^2.18.1"
},
"devDependencies": {
"nodemon": "^2.0.15"
}
}
When trying to run npm run devStart on visual studio code terminal for mac I get the following errors
% npm run devStart
npm ERR! Missing script: "devStart"
npm ERR! Did you mean this?
npm ERR! npm restart # Restart a package
npm ERR! To see a list of scripts, run:
npm ERR! npm run
...

Access denied nsis electron builder

When I package using electron-builder, it shows an error access denied, I came across a post that says it has something to do with the firewall but how will I disable it in windows.
The Error
C:\Users\dell\AppData\Local\electron-builder\Cache\nsis\566152007 C:\Users\dell\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1: Access is denied.
тип ENOENT: no such file or directory, copyfile 'C:\Users\dell\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\elevate.exe' -> 'C:\Users\dell\Desktop\opcoin\download\app\dist\win-unpacked\resources\elevate.exe' failedTask=build stackTrace=Error: ENOENT: no such file or directory, copyfile 'C:\Users\dell\AppData\Local\electron-builder\Cache\nsis\nsis-3.0.4.1\elevate.exe' -> 'C:\Users\dell\Desktop\opcoin\download\app\dist\win-unpacked\resources\elevate.exe'
at processImmediate (internal/timers.js:461:21)
From previous event:
at NsisTarget.buildInstaller (C:\Users\dell\Desktop\opcoin\download\app\node_modules\app-builder-lib\src\targets\nsis\NsisTarget.ts:223:29)
at NsisTarget.finishBuild (C:\Users\dell\Desktop\opcoin\download\app\node_modules\app-builder-lib\src\targets\nsis\NsisTarget.ts:129:9)
at async Promise.all (index 1)
at AsyncTaskManager.awaitTasks (C:\Users\dell\Desktop\opcoin\download\app\node_modules\builder-util\src\asyncTaskManager.ts:65:25)
at Packager.doBuild (C:\Users\dell\Desktop\opcoin\download\app\node_modules\app-builder-lib\src\packager.ts:453:5)
at Object.executeFinally (C:\Users\dell\Desktop\opcoin\download\app\node_modules\builder-util\src\promise.ts:12:14)
at Packager._build (C:\Users\dell\Desktop\opcoin\download\app\node_modules\app-builder-lib\src\packager.ts:376:31)
at Packager.build (C:\Users\dell\Desktop\opcoin\download\app\node_modules\app-builder-lib\src\packager.ts:337:12)
at Object.executeFinally (C:\Users\dell\Desktop\opcoin\download\app\node_modules\builder-util\src\promise.ts:12:14)
npm ERR! code ELIFECYCLE
Package.json:
{
"name": "opcoin",
"version": "1.0.0",
"description": "OpCoin Grabber",
"main": "app.js",
"scripts": {
"start": "electron .",
"dist": "electron-builder",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"electron": "^14.0.1",
"electron-builder": "^22.11.7"
},
"build": {
"appId": "com.aryaanish.opcoin",
"productName": "Op Coin Grabber",
"target": "NSIS",
"nsis": {
"allowToChangeInstallationDirectory": true,
"oneClick": false
},
"win": {
"icon": "build/icon.ico"
}
}
}
Fix
I restarted my computer and it worked but the correct answer is given by #Casimir Crystal in the comment

tried to npm link and run the package after but throws an error "no such file"

i did an npm link to my node package for generating password. however, after npm link and it throws these error:
npm WARN saveError ENOENT: no such file or directory, open '/Users/valeryfun/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/Users/valeryfun/package.json'
i've included bin and repository type, but i still cant run the package.
here's the package.json file:
{
"name": "password-generator",
"version": "1.0.0",
"private": true,
"description": "A password generator",
"main": "index.js",
"preferGlobal": true,
"bin": {
"password-generator": "./index.js"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Valery",
"license": "MIT",
"dependencies": {
"chalk": "^4.1.1",
"clipboardy": "^2.3.0",
"commander": "^8.1.0"
},
"repository": {
"type": "git",
"url": "https://github.com/valeryfun/password-generator-lazy.git"
}
}
did i miss out anything such that I couldn't use the package after linking it?

framework7: npm ERR! missing script: serve on package.json

I added serve keyword inside package.json with localhost:8080 as it's value but it wont work. I tried using localhost ip address instead of "localhost" still got error.
On my package.json
{
"name": "package-lock",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"framework7": "^3.0.1"
},
"devDependencies": {},
"scripts": {
"serve":"localhost:8080",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}

Resources