How to fix NPM EJSONParse with this package.json file? - node.js

when I try the command npm install I have this
C:\Users\khaou>npm install
npm ERR! code EJSONPARSE
npm ERR! path C:\Users\khaou/package.json
npm ERR! JSON.parse Unexpected end of JSON input while parsing empty string
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: 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\khaou\AppData\Local\npm-cache\_logs\2021-12-31T16_42_25_903Z-debug.log
This is the JSON:
{
"name": "eth-todo-list",
"version": "1.0.0",
"description": "Blockchain Todo List Powered By Ethereum",
"main": "truffle-config.js",
"directories": {
"test": "test"
},
"scripts": {
"dev": "lite-server",
"test": "echo \"Error: no test specified\" && sexit 1"
},
"author": "gregory#dappuniversity.com",
"license": "ISC",
"devDependencies": {
"bootstrap": "4.1.3",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^2.0.2",
"lite-server": "^2.3.0",
"nodemon": "^1.17.3",
"truffle": "5.0.2",
"truffle-contract": "3.0.6"
}
}

Probably your file association is other than JavaScript like JavaScript react or any other.
Check your package.json settings file to have Item:javascript Value:javascript as default extension (*) on Files:Associations.
package.json->file->preferences->settings->Files:Associations
Item:javascript Value:javascript
Hope it works!

Related

Error installing vscode.d.ts: Error: Request returned status code: 404

I found a forum with this problem and I followed all of their steps but it still doesn't work, please help me, any help would be greatly appreciated.
Also when I try to go into https://raw.githubusercontent.com/Microsoft/vscode/30d9c6cd9483b2cc586687151bcbcd635f373630/src/vs/vscode.d.ts It also returns 404: not found
Error:
> shinomy#1.0.0 postinstall
> node ./node_modules/vscode/bin/install
Detected VS Code engine version: ^1.68.1
Found minimal version that qualifies engine range: 1.68.1
Fetching vscode.d.ts from: https://raw.githubusercontent.com/Microsoft/vscode/30d9c6cd9483b2cc586687151bcbcd635f373630/src/vs/vscode.d.ts
Error installing vscode.d.ts: Error: Request returned status code: 404
npm ERR! code 1
npm ERR! path C:\Users\Lenovo\Desktop\Shinomy
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./node_modules/vscode/bin/install
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Lenovo\AppData\Local\npm-cache\_logs\2022-06-21T07_50_15_855Z-debug-0.log
My package.json
{
"name": "shinomy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"postinstall": "node ./node_modules/vscode/bin/install"
},
"engines": {
"vscode": "^1.68.1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#types/vscode": "^1.68.0",
"bcrypt": "^5.0.1",
"discord.js": "^13.6.0",
"mongo": "^0.1.0",
"mongodb": "^4.6.0",
"mongoose": "^6.3.3",
"mongoose-unique-validator": "^3.0.0",
"node-mailer": "^0.1.1",
"nodemon": "^2.0.16",
"path": "^0.12.7",
"quick.db": "^7.1.3",
"speakeasy": "^2.0.0",
"vscode": "^1.1.37"
}
}
Read the NPM page of vscode
This package is deprecated in favor of #types/vscode and vscode-test. For more information please read: https://code.visualstudio.com/updates/v1_36#_splitting-vscode-package-into-typesvscode-and-vscodetest

Postinstall of module is executed before postinstall of sub-module

Edit:
I'm asking how to install it from GitHub, not npm, that the question.
In case you want to know why: I'm working on some private projects and don't what t publish the code. This leads to the code being in a private repository, not published on npm.
Original post:
Trying to install a module from GitHub (it is in typescript, thus I need a compilation script [postinstall]). It seems to fail because one of the module dependencies is also on GitHub, and that postinstall script is not waited on by the current postinstall script.
Old GitHub issue that sounds related: https://github.com/npm/npm/issues/5001
Yes, like the issue, I also use the same dependency in the main project as the module does.
Program
Version
node
v16.1.0
npm
7.11.2
npm info run newton#1.0.1 postinstall node_modules/newton tsc -d -p .
npm info run nodemon#2.0.7 postinstall node_modules/nodemon node bin/postinstall || exit 0
npm info run rendery#2.0.0 postinstall node_modules/rendery tsc -d -p .
npm info run nodemon#2.0.7 postinstall { code: 0, signal: null }
npm timing build:run:postinstall:node_modules/nodemon Completed in 157ms
npm info run newton#1.0.1 postinstall { code: 0, signal: null }
npm timing build:run:postinstall:node_modules/newton Completed in 2409ms
npm info run rendery#2.0.0 postinstall { code: 2, signal: null }
npm timing reify:rollback:createSparse Completed in 2864ms
npm timing reify:rollback:retireShallow Completed in 0ms
npm timing command:install Completed in 47807ms
npm verb stack Error: command failed
npm verb stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
npm verb stack at ChildProcess.emit (node:events:365:28)
npm verb stack at maybeClose (node:internal/child_process:1067:16)
npm verb stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm verb pkgid rendery#2.0.0
npm verb cwd C:\Users\Elias\git\natrias
npm verb Windows_NT 10.0.19043
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "--verbose" "--force"
npm verb node v16.1.0
npm verb npm v7.11.2
npm ERR! code 2
npm ERR! path C:\Users\Elias\git\natrias\node_modules\rendery
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c tsc -d -p .
npm ERR! src/2d/CanvasRenderyContext2D.ts(1,29): error TS2307: Cannot find module 'newton/2d/ReadonlyVector2' or its corresponding type declarations.
npm ERR! src/2d/CanvasRenderyContext2D.ts(2,21): error TS2307: Cannot find module 'newton/2d/Vector2' or its corresponding type declarations.
npm ERR! src/2d/ReadonlyRenderyContext2D.ts(1,29): error TS2307: Cannot find module 'newton/2d/ReadonlyVector2' or its corresponding type declarations.
npm ERR! src/2d/RenderyContext2D.ts(1,29): error TS2307: Cannot find module 'newton/2d/ReadonlyVector2' or its corresponding type declarations.
npm verb exit 2
npm timing npm Completed in 48318ms
npm verb code 2
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Elias\AppData\Local\npm-cache\_logs\2021-05-12T16_19_34_975Z-debug.log
Note that rendery postinstall starts before newton postinstall completes.
Newton package.json
{
"name": "newton",
"version": "1.0.1",
"description": "",
"scripts": {
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"postinstall": "tsc -d -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0"
},
"dependencies": {
"typescript": "^4.2.4"
}
}
Rendery package.json
{
"name": "rendery",
"version": "2.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"postinstall": "tsc -d -p ."
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-typescript-sort-keys": "^1.6.0"
},
"dependencies": {
"newton": "github:Elias-Graf/newton#main",
"typescript": "^4.2.4"
}
}
It's not a good practice to publish unbuilt packages. I recommend changing the postinstall script into a prepare script so it builds the package before publishing it.
{
"name": "newton",
"version": "1.0.1",
"description": "",
"scripts": {
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"prepare": "tsc -d -p .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0"
},
"dependencies": {
"typescript": "^4.2.4"
}
}
{
"name": "rendery",
"version": "2.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "eslint '*/**/*.ts'",
"lint:fix": "eslint '*/**/*.ts' --fix",
"prepare": "tsc -d -p ."
},
"keywords": [],
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint": "^7.25.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"eslint-plugin-typescript-sort-keys": "^1.6.0"
},
"dependencies": {
"newton": "github:Elias-Graf/newton#main",
"typescript": "^4.2.4"
}
}
This would fix your issue.

node start error in Windows

Windows MEVN stack project
i have npm start terminal output:
$ npm start
> nodejs-starter#1.0.0 start C:\final-dip\diplom-master
> SECRET=diplom nodemon index.js
"SECRET" is not internal or external
command, executable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nodejs-starter#1.0.0 start: `SECRET=diplom nodemon index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs-starter#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Admin\AppData\Roaming\npm-cache\_logs\2018-05-04T10_33_19_073Z-debug.log
code in package.json:
{
"name": "nodejs-starter",
"version": "1.0.0",
"description": "A boilerplate for NodeJS web servers",
"main": "index.js",
"scripts": {
"start": "SECRET=diplom nodemon index.js",
"init": "node ./controllers/init",
"debug": "cross-env PORT=3333 SECRET=GREEN_BUS nodemon --inspect index.js"
},
"keywords": [],
"author": "Almat Ybray",
"license": "MIT",
"devDependencies": {
"eslint": "^4.14.0",
"nodemon": "^1.14.7"
},
"dependencies": {
"async": "^2.6.0",
"body-parser": "^1.18.2",
"cookie-parser": "^1.4.3",
"cors": "^2.8.4",
"express": "^4.16.2",
"express-jwt": "^5.3.1",
"express-validator": "^5.0.3",
"helmet": "^3.9.0",
"jsonwebtoken": "^8.2.0",
"mongoose": "^5.0.0-rc1",
"morgan": "^1.9.0",
"multer": "^1.3.0",
"passport": "^0.4.0",
"passport-local": "^1.0.0",
"socket.io": "^2.0.4"
}
}
You're missing cross-env for your start script. Change your package.json to:
{
"scripts": {
"start": "cross-env SECRET=diplom nodemon index.js"
}
}
It's already being used in the debug script.
NOTE It's also not part of dependencies so it has to be added via npm i cross-env --save.

Could not find files on devDependencies

I have a package.json file that looks as following:
{
"name": "basics",
"version": "0.1.0",
"private": true,
"devDependencies": {
"concurrently": "3.4.0",
"react-scripts": "1.0.14",
"fsr-helpers": "file:../../fsr-helpers"
},
"dependencies": {
"history": "4.3.0",
"prop-types": "15.6.0",
"react": "16.0.0",
"react-dom": "16.0.0",
"react-router-dom": "4.2.2"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"eject": "react-scripts eject",
"e2e": "nightwatch",
"run-e2e": "./node_modules/.bin/concurrently -k 'npm start' 'npm run e2e'"
}
}
During the installation of packages, I've got the following error message:
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: core-js#2.4.1 (node_modules/fsr-helpers/node_modules/babel-polyfill/node_modules/core-js):
npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/home/developer/Desktop/fullstack-react-code/routing/basics/node_modules/.staging/core-js-4f416826' -> '/home/developer/Desktop/fullstack-react-code/fsr-helpers/node_modules/babel-polyfill/node_modules/core-js'
npm ERR! Maximum call stack size exceeded
npm ERR! A complete log of this run can be found in:
npm ERR! /home/developer/.npm/_logs/2018-03-01T21_00_59_918Z-debug.log
I suppose, that the error occurs, because of:
"fsr-helpers": "file:../../fsr-helpers"
in the devDependencies. The structure of the folder looks like:
and the content of the package.json is:
{
"name": "fsr-helpers",
"version": "1.0.0",
"private": true,
"main": "dist/index.js",
"dependencies": {
"react": "15.5.4",
"react-dom": "15.5.4"
},
"scripts": {
"test": "jest src --watch",
"compile": "./node_modules/.bin/babel -d dist/ src/"
},
"devDependencies": {
"babel-cli": "6.24.0",
"babel-core": "6.24.0",
"babel-jest": "19.0.0",
"babel-plugin-transform-es2015-modules-commonjs": "6.24.0",
"babel-preset-es2016": "6.22.0",
"babel-preset-react": "6.23.0",
"babel-preset-stage-2": "6.22.0",
"enzyme": "2.8.2",
"jest": "19.0.2",
"react-test-renderer": "16.0.0"
}
}
Why do I get the error:
Maximum call stack size exceeded
What does "fsr-helpers": "file:../../fsr-helpers" mean?
The "file:" syntax is a way to use local path to a package: https://docs.npmjs.com/files/package.json#local-paths
In your case it is looking for package the 2 levels up from the package.json (../../)
It should be file:./fsr-helpers instead if I read your folder structure correctly (in a folder directly inside your project).

npm run start with "DEBUG=*" issue on Windows

{
"name": "apokidsi",
"version": "0.717",
"contributors": [
],
"dependencies": {
"angular": "1.5.8",
"angular-cookies": "1.5.8",
"angular-messages": "1.5.8",
"angular-ui-router": "1.0.0-beta.3",
"debug": "^3.0.0",
"flag-icon-css": "2.8.0",
"jquery": "3.2.1",
"moment": "2.18.1",
"moment-timezone": "0.5.13",
"node-fetch-npm": "^2.0.1"
},
"scripts": {
"clean": "gulp clean",
"start": "DEBUG=true HOST=localhost:4200 gulp server",
}
}
Here is the package.json file.
When I run npm run start
I get this message
'DEBUG' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
After checking all the possibilities we have to use the cross-env dependencies.
so install npm install cross-env --save-dev
and in package.json
"Start": " cross-env-shell DEBUG=True HOST=dev.example.com gulp server"

Resources