Node.js npm错误!代码EJSONPARSE npm安装,husky和lint处于暂存状态
mypackage.json可以在没有husky和lint的情况下工作,但不能与它们一起工作。 它说:Node.js npm错误!代码EJSONPARSE npm安装,husky和lint处于暂存状态,node.js,package.json,prettier,husky,lint-staged,Node.js,Package.json,Prettier,Husky,Lint Staged,mypackage.json可以在没有husky和lint的情况下工作,但不能与它们一起工作。 它说: npm ERR! code EJSONPARSE npm ERR! file C:\Proyectos\my-app\package.json npm ERR! JSON.parse Failed to parse json npm ERR! JSON.parse Unexpected token in JSON at position 1254 while parsing near '.
npm ERR! code EJSONPARSE
npm ERR! file C:\Proyectos\my-app\package.json
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token in JSON at position 1254 while parsing near '...
npm ERR! JSON.parse "lint-staged": {
npm ERR! JSON.parse "*.{...'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
我在package.json中添加的是
“哈士奇”:{
“挂钩”:{
“预提交”:“npm运行测试&prettier--write”,
“预推送”:“npm运行测试&prettier--write”
}
},
“林特舞台”:{
"*.{ts,tsx}": [
“更漂亮——写”,
“git添加”
]
}
一些用户要求我上传整个package.json,下面是代码
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.19.3",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"@types/styled-components": "^5.1.4",
"lint-staged": "^10.5.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"typescript": "^4.0.5",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "2.1.2",
"styled-components": "^5.2.1"
},
"husky": {
"hooks": {
"pre-commit": "npm run test && prettier --write",
"pre-push": "npm run test && prettier --write"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"git add"
]
}
}
现在试试这个
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.5",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"@types/jest": "^26.0.15",
"@types/node": "^12.19.3",
"@types/react": "^16.9.55",
"@types/react-dom": "^16.9.9",
"@types/styled-components": "^5.1.4",
"lint-staged": "^10.5.1",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"typescript": "^4.0.5",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"prettier": "2.1.2",
"styled-components": "^5.2.1"
},
"husky": {
"hooks": {
"pre-commit": "npm run test && prettier --write",
"pre-push": "npm run test && prettier --write"
}
},
"lint-staged": {
"*.{ts,tsx}": [
"prettier --write",
"git add"
]
}
}
使用验证
包.json
检查package.json
文件。它可能包含我们必须删除的额外逗号(,)或双引号(“”)
这对我有效。有一些特殊字符被添加到你的文件中,我删除了这些字符。这是
package.json的工作副本
是的,但没有,我有新的错误npm ERR!code ELIFECYCLE