npm ERR! package.json must be actual JSON, not just JavaScript - json

Newbie node question. I am not able to get my project running anymore.
{
"name": "MyApp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js dev2"
},
"author": "",
"license": "ISC",
"dependencies": {
"async-await": "^0.1.32",
"asyncawait": "^1.0.3",
"body-parser": "^1.14.2",
"deasync": "",
"ejs": "^2.4.1",
"express": "^4.13.4",
"gulp": "^3.9.0",
"gulp-concat": "",
"gulp-filelist": "^0.2.0",
"gulp-foreach": "^0.1.0",
"gulp-remove-files": "0.0.3",
"gulp-rename": "",
"gulp-uglify": "",
"gulp-watch": "^4.3.5",
"mongoose": "^4.4.1",
"mongoose-ttl": "0.0.3",
"node-inspector": "^0.12.5",
"promise": "^7.1.1",
"rootpath": "^0.1.2"
},
"devDependencies": {
"browser-sync": "^2.11.1",
"gulp": "^3.9.1"
}
}
1726 error Failed to parse json
1726 error Unexpected token '\u0000' at 1:1
1726 error
1726 error ^
1727 error File: C:\Users\dir\AppData\Roaming\npm-cache\accepts\1.2.13\package\package.json
1728 error Failed to parse package.json data.
1728 error package.json must be actual JSON, not just JavaScript.

error Unexpected token '\u0000' at 1:1
seems that u have null character at first line and 1 character
can u provide package.json on pastebin or similar?

Related

The react-scripts package provided by Create React App requires a dependency : Babel-Jest

I found this error message when running react-script test
The react-scripts package provided by Create React App requires a dependency "babel-jest": "^24.9.0"`
So the error message also recommend us to remove package-lock.json and also node_modules I tried but I have the same error message.
And I inspect the package-lock.json and for example jest-config (is a sub dependancies) use higher version than react-script accept.
Please if you have some advices
packages.json
{
"name": "creator-web-app",
"version": "0.1.0",
"private": true,
"main": "public/electron.js",
"homepage": "./",
"dependencies": {
"#craco/craco": "^5.6.4",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.5.0",
"#testing-library/user-event": "^7.2.1",
"#types/react": "^16.9.34",
"await-to-js": "^2.1.1",
"axios": "^0.19.2",
"classnames": "^2.2.6",
"electron-is-dev": "^1.2.0",
"env-cmd": "^10.1.0",
"enzyme": "^3.11.0",
"history": "^4.10.1",
"i18next": "^19.4.2",
"i18next-browser-languagedetector": "^4.0.2",
"jest": "^25.3.0",
"jwt-decode": "^2.2.0",
"moment": "^2.24.0",
"nano-id": "^1.1.0",
"npm-watch": "^0.6.0",
"react": "^16.13.1",
"react-cookies": "^0.1.1",
"react-dom": "^16.13.1",
"react-i18next": "^11.3.4",
"react-inlinesvg": "^1.2.0",
"react-redux": "^7.2.0",
"react-router-dom": "5.1.2",
"react-scripts": "3.4.1",
"redux": "^4.0.5",
"redux-form": "^8.3.3",
"redux-thunk": "^2.3.0",
"typescript": "^3.7.0"
},
"scripts": {
"electron": "NODE_ENV=production npm run build && NODE_ENV=production electron .",
"start": "NODE_ENV=development react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"pack": "NODE_ENV=production && npm run build && electron-builder --dir",
"dist": "NODE_ENV=production && npm run build electron-builder"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/classnames": "^2.2.10",
"#types/enzyme": "^3.10.5",
"#types/jest": "^25.2.1",
"#types/react-redux": "^7.1.7",
"#types/react-router-dom": "^5.1.4",
"#types/redux-form": "^8.2.3",
"craco-alias": "^2.1.1",
"electron": "^8.2.1",
"electron-builder": "^22.4.1",
"enzyme-adapter-react-16": "^1.15.2",
"node-sass": "^4.13.1",
"react-test-renderer": "^15.6.2",
"ts-jest": "^25.4.0",
"whatwg-fetch": "^3.0.0"
},
"build": {
"appId": "studioapp.id",
"mac": {
"category": "your.app.category.type"
},
"files": [
"**/*"
],
"directories": {
"buildResources": "."
},
"protocols": {
"name": "studioapp-protocol",
"schemes": [
"studioapp"
]
}
},
"jest": {
"collectCoverageFrom": [
"<rootDir>/src/**/*.{ts,tsx}"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|yml)$": "<rootDir>/tests/test-file-mock.js",
"\\.(css|less|scss|sss|styl)$": "<rootDir>/tests/test-mock.js",
"#/(.*)$": "<rootDir>/src/$1"
},
"transform": {
"^.+\\.(tsx|ts)?$": "ts-jest"
}
}
}
Thanks
I faced the same problem with create-react-app. Here is what I did
Go to the path
C:\Users\YOURNAME\node_modules
and then remove those packages which show an error.
More information here: https://github.com/creativetimofficial/argon-dashboard-react/issues/28
Ironically I was working on a similarish problem this morning. Could you provide a screenshot of your package.json and the error message?
Babel-Jest is used to compile javascript code into a format that jest can consume. I suspect that your problem is that you have a dependency that the lock file has subsequently locked in the incorrect version of babel-jest.
I can add some more details from the above response for solve this issue I found the problem.
When we use react-scripts we can't have jest packages or something is already manage by create-react-app
The problem when I have is package.json contain jest at superior version than react-script can accept
When I deleted this line in my package.json already seems to work
One of your dependencies is using a newer version of babel-jest. You can find which ones they are by running npm ls babel-jest in your project root directory.
A simple way to fix the problem then, is to try and link to an older version of those packages, e.g. "#types/jest": "^24.0.0" so that they don't use the newer version of babel-jest.
for mac user remove
/Users/{UserName}/node_modules

An unexpected error occurred: "/home/kudzie/portfolio/package.json: Unexpected token } in JSON at position 575"

trying to build a GitHub portfolio and host it on Namecheap so having this error: An unexpected error occurred: "/home/kudzie/portfolio/package.json: Unexpected token } in JSON at position 575".
{
"name": "portfolio",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "yarn run build",
"deploy": "gh-pages -d build"
},
"homepage":{
"http://kgomera.me/."
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
trying to build a GitHub portfolio and host it on Namecheap so having the error l posted above
On your "homepage" line:
"homepage":{
"http://kgomera.me/."
}
it is expecting a property, but all that's there is a string.
There are a couple ways of fixing this. The first, which is probably the way you're intending, is to change "homepage" from an object to a property:
"homepage":"http://kgomera.me/."
Secondly, you could add a key to make it into a property
"homepage":{
"url":"http://kgomera.me/."
}
Or lastly, you could make it into an array instead of an object by replacing the curly brackets with square brackets
"homepage":[
"http://kgomera.me/."
]
Just for future situations like this, here is a fantastic JSON validator and formatter that tells you exactly what is happening.

Trying to run npm run dev "No entries found."

When I'm running "npm run dev" it gives me this error:
Server running at http://localhost:1234
🚨 No entries found.
at Bundler.bundle (/Users/igoraccebas/node_modules/parcel-bundler/src/Bundler.js:275:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # dev: parcel react/src/react.html
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Here is my package.json file
{
"name": "adopt-me",
"version": "1.0.0",
"description": "An app to teach you to write React",
"main": "react/src/App.js",
"scripts": {
"test": "",
"format": "prettier --write \"src/**/*.{js,jsx}\"",
"lint": "eslint \"src/**/*.{js,jsx}\" --quiet",
"dev": "parcel react/src/react.html"
},
"repository": {
"type": "git",
"url": "git+https://github.com/btholt/complete-intro-to-react-v4.git"
},
"author": "Brian Holt <btholt#gmail.com>",
"license": "Apache-2.0",
"bugs": {
"url": "https://github.com/btholt/complete-intro-to-react-v4/issues"
},
"homepage": "https://github.com/btholt/complete-intro-to-react-v4#readme",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-eslint": "^8.2.6",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"eslint": "^5.3.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jsx-a11y": "^6.1.1",
"eslint-plugin-react": "^7.10.0",
"parcel-bundler": "^1.12.3",
"prettier": "^1.14.2"
},
"dependencies": {
"#reach/router": "^1.1.1",
"petfinder-client": "^0.0.3",
"react": "^16.4.2",
"react-dom": "^16.4.2"
}
}
Instead of this
"dev": "parcel react/src/react.html"
do this
"dev": "parcel src/react.html"
You should use main directory like that: frontend/index.html

Getting undefined is not an object

I am looking for sample project of React-Native. First of all i got erro which is unable to resolve router flux. Then i added flux dependency and i run npm start. After that i got "Undefined is not an object" in package.json. How can i solve it. Can you please help me?
{
"name": "FirsTrial",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"react": "16.3.1",
"react-native": "0.55.3",
"react-native-router-flux": "3.38.0"
},
"devDependencies": {
"babel-jest": "22.4.3",
"babel-preset-react-native": "^2.1.0",
"jest": "22.4.3",
"react-test-renderer": "16.3.1"
},
"jest": {
"preset": "react-native"
}
}
"FirsTrial" is underlined !!!

ESLINT: Parsing error: Unexpected token in package.json

{
"name": "react-redux-starter-kit",
"version": "1.0.0",
"description": "This would be the starter kit for react projects.",
"main": "index.html",
"scripts": {
"start": "rm -rf build/ && rm -rf dist/ && webpack && webpack-dev-server --progress --colors",
"build": "rm -rf build/ && rm -rf dist/ && NODE_ENV=production webpack --config ./webpack.production.config.babel.js --progress"
},
"repository": {
"type": "git",
"url": "git+https://rahulshettyprdxn#bitbucket.org/rahulshettyprdxn/react-devops.git"
},
"keywords": [
"react",
"webpack",
"react-native"
],
"author": "Rahul Shetty",
"license": "MIT",
"homepage": "https://bitbucket.org/rahulshettyprdxn/react-devops#readme",
"devDependencies": {
"babel-core": "^6.5.2",
"babel-eslint": "^5.0.0",
"babel-loader": "^6.2.3",
"babel-plugin-react-transform": "^2.0.0",
"babel-preset-es2015-without-strict": "0.0.2",
"babel-preset-react": "^6.5.0",
"css-loader": "^0.23.1",
"eslint": "^2.2.0",
"eslint-plugin-react": "^4.1.0",
"extract-text-webpack-plugin": "^1.0.1",
"file-loader": "^0.8.5",
"html-webpack-plugin": "^2.9.0",
"image-webpack-loader": "^1.6.3",
"node-sass": "^3.4.2",
"react-css-modules": "^3.7.5",
"react-transform-hmr": "^1.0.2",
"sass-loader": "^3.1.2",
"style-loader": "^0.13.0",
"webpack": "^1.12.14",
"webpack-dev-server": "^1.14.1"
},
"dependencies": {
"bootstrap": "^3.3.6",
"react": "^0.14.7",
"react-bootstrap": "^0.28.3",
"react-dom": "^0.14.7"
}
}
Below is the error that I am receiving:
Parsing error: Unexpected token at line 2 col 8 in Atom editor.
Note that I'm currently getting this error on Windows 10.
ESLint Version:
"eslint": "^2.2.0",
"eslint-plugin-react": "^4.1.0"
I have installed linter-eslint in my Atom editor and Global npm ESLint setting is off.
I am quite confused as the error message is not that descriptive. This in no way is hampering my project but I am quite inquisitive as to why I am getting this error in my editor.
ESLint is for validating JavaScript, not JSON.
From the website:
ESLint
The pluggable linting utility for JavaScript and JSX
[emphasis mine]
(You can try your code on the online demo here, and you get the same error)
If you want to use ESLint on a JSON file, you could use a package like eslint-plugin-json.