How i can handle an error in package.json? - node.js

i m having a problem with the package.json. This is a cloned project,and and i revised the commas and they are ok. so i don't know where is the mistake.
This is what the terminal says:
npm ERR! code EJSONPARSE
npm ERR! file C:\Users\Emege\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected end of JSON input while parsing near ''
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\Emege\AppData\Roaming\npm-cache\_logs\2020-08-22T03_04_56_980Z-debug.log.
I read this article, but it didn't help me https://dev.to/redslug/7-solutions-to-ejsonparse-or-unexpected-token-npm-install-error-20nh.
And this is the package.json
{
"name": "tvpassport",
"version": "1.0.0",
"description": "Autentificacion de usuarios",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jean Mariños",
"license": "ISC",
"dependencies": {
"body-parser": "^1.14.1",
"connect-flash": "^0.1.1",
"connect-redis": "^3.0.1",
"express": "^4.13.3",
"express-session": "^1.12.1",
"mongoose": "^4.2.5",
"passport": "^0.3.2",
"passport-facebook": "^2.0.0",
"passport-local": "^1.0.0",
"swig": "^1.4.2"
}
}

You need only this in you package.json file:
{
"name": "tvpassport",
"version": "1.0.0",
"description": "Autentificacion de usuarios",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Jean Mariños",
"license": "ISC",
"dependencies": {
"body-parser": "^1.14.1",
"connect-flash": "^0.1.1",
"connect-redis": "^3.0.1",
"express": "^4.13.3",
"express-session": "^1.12.1",
"mongoose": "^4.2.5",
"passport": "^0.3.2",
"passport-facebook": "^2.0.0",
"passport-local": "^1.0.0",
"swig": "^1.4.2"
}
}
remove this: ````````

Related

Can't install NPM in cpanel with sharp any version

I am using sharp to convert images to webp (project developped with angular + nodejs), it works only localy because i have error when i deploy using Cpanel (nodejs apps), i checked with different versions (latest 0.31.1, 0.27.0 and also 0.23.0 ..). I can install sharp if only i remove it from dependencies :
"dependencies": {
"sharp": "^0.27.0"
Have you any idea ?
Thanks.
Here is error :
npm WARN lifecycle The node binary used for scripts is /home/xxx/nodevenv/nodejs_test/10/bin/node but npm is using /opt/alt/alt-nodejs10/root/usr/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary ....
Here is my package.json :
{
"name": "mysqlproject",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"sharp": "^0.27.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"express": "^4.17.1",
"file": "^0.2.2",
"material-icons": "^0.6.1",
"multer": "^1.4.4",
"mysql": "^2.18.1",
"node-fetch": "^3.2.3",
"nodemailer": "6.6.3",
"nodemon": "^2.0.7",
"request": "^2.88.2",
"typeface-open-sans": "^1.1.13",
"typeface-roboto": "^1.1.13"
},
"browser": {
"fs": false,
"path": false,
"os": false,
"crypto": false
}
}

Not able to install project dependencies NodeJS

I am trying to install dependency in a project but getting this error. I already upgraded all dependencies and versions of npm but that's not working for me.
Package.json:
{
"name": "task",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.0",
"body-parser": "^1.19.0",
"connect-mongo": "^3.2.0",
"ejs": "^3.1.6",
"express": "^4.18.1",
"express-fileupload": "^1.4.0",
"express-flash": "^0.0.2",
"express-session": "^1.17.3",
"lodash": "^4.17.21",
"mongodb": "^4.9.1",
"mongoose": "^6.0.5",
"multer": "^1.4.3",
"node": "^16.6.1",
"nodemailer": "^6.7.0",
"nodemon": "^2.0.13",
"open": "^8.4.0",
"passport": "^0.6.0",
"passport-local": "^1.0.0",
"simplebar": "^5.3.5"
}
}

Failed to deploy nodejs into azure

I am trying to deploy my web apps to azure web apps via azure apps in vscode, but when I try to deploy and I check the results it came out ':( Application Error'. How can I deploy successfully? and I check stream log this is the result :
2020-02-21T13:50:37.648590306Z npm ERR! errno ENOENT
2020-02-21T13:50:37.651449357Z npm ERR! script#1.0.0 start: `npx babel src -s -D -d dist && node dist/main.js`
2020-02-21T13:50:37.652176195Z npm ERR! spawn ENOENT
2020-02-21T13:50:37.652917034Z npm ERR!
2020-02-21T13:50:37.653579369Z npm ERR! Failed at the script#1.0.0 start script.
2020-02-21T13:50:37.654141399Z npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-02-21T13:50:37.660881655Z
2020-02-21T13:50:37.661645395Z npm ERR! A complete log of this run can be found in:
2020-02-21T13:50:37.662200124Z npm ERR! /root/.npm/_logs/2020-02-21T13_50_37_655Z-debug.log
can someone help me ? how to make
this my package json :
{
"name": "test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "npx babel src -s -D -d dist && node dist/main.js",
"build": "npx babel src -s -D -d dist",
"dev": "nodemon --exec babel-node src/main.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"axios": "^0.19.2",
"body-parser": "^1.19.0",
"dotenv": "^8.2.0",
"ejs": "^3.0.1",
"express": "^4.17.1",
"express-handlebars": "^3.1.0",
"express-recaptcha": "^5.0.1",
"form-data": "^3.0.0",
"moment": "^2.24.0",
"multer": "^1.4.2",
"node-fetch": "^2.6.0",
"php-serialize": "^3.0.1",
"request": "^2.88.2",
"request-promise": "^4.2.5",
"store": "^2.0.12",
"streamifier": "^0.1.1",
"url": "^0.11.0",
"util": "^0.12.1"
},
"devDependencies": {
"#babel/cli": "^7.6.2",
"#babel/core": "^7.6.2",
"#babel/node": "^7.6.2",
"#babel/plugin-transform-runtime": "^7.6.2",
"#babel/preset-env": "^7.6.2",
"#babel/preset-flow": "^7.0.0",
"#babel/runtime": "^7.6.2",
"babel-core": "^7.0.0-bridge.0",
"babel-node": "0.0.1-security",
"babel-polyfill": "^6.26.0"
}
}

repeated EJSONPARSE error

"npm run react-dev" command gives this jsonparse error occurs repeatedly.
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token in JSON at position 595 while parsing ' {
npm ERR! "name": "reactnodetutorial",
npm ERR! "vers'
Tried the following but none worked.
1) deleted all directories and files and restarted this project from the scratch like building architecture and installing dependencies
2) deleted all contents in package.json file and copied the tutorial example's package.json contents which is perfect and pasted it to mine
3) update node and npm to the latest version
4) npm init and reinstall dependencies
5) npm cache clean --force
6) rm -f package-lock.json
How to possibly fix this.
My package.json file is as follows:
{
"name": "reactnodetutorial",
"version": "1.0.0",
"description": "",
"main": "webpack.config.js",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"body-parser": "^1.18.2",
"express": "^4.16.3",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"webpack": "^4.1.1"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "webpack -d --watch",
"start": "node ./server/index.js",
"build": "webpack -p",
"react-dev": "webpack -d --watch",
"server-dev": "nodemon server/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/shinjehere/reactNodeTutorial.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/shinjehere/reactNodeTutorial/issues"
},
"homepage": "https://github.com/shinjehere/reactNodeTutorial#readme"
}

behavior differs for npm install and npm install -g

In order to build frontend sources on Windows 7 with gulp.js I have a package.json file with node_modules dependencies defined in it:
{
"name": "custom-repo-name",
"version": "1.0.0",
"description": "",
"main": "gulpfile.js",
"directories": {
"doc": "doc"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"gulp-concat": "^2.5.2",
"gulp-stylus": "^2.0.3",
"gulp-uglify": "^1.2.0",
"rimraf": "^2.3.4"
},
"devDependencies": {
"gulp": "^3.9.0",
"gulp-concat": "^2.5.2",
"gulp-rev": "^4.0.0",
"gulp-stylus": "^2.0.3",
"gulp-uglify": "^1.2.0",
"gulp-watch": "^4.2.4",
"rimraf": "^2.3.4"
}
}
For some reason when I run
npm install
the dependencies are installed locally into .\node_modules folder and gulp command runs properly.
But when I run
npm install -g,
as I can see from the output, a part of dependencies is missing to be installed and running gulp command fails with an error of failed load of dependencies (gulp-uglify.js for instance).
What's wrong?

Resources