我正在尝试使此模板正常工作,但它在npm启动时一直给我错误。 我已经尝试过重新安装npm,清除npm-cache和更改版本。我在package.JSON文件中找不到任何错误。
这是错误
npm start
npm ERR! file /home/singhanurag9080/Downloads/material-react/material-kit-react-master/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token { in JSON at position 27 while parsing near '...ckfileVersion": 1
npm ERR! JSON.parse }
npm ERR! JSON.parse {
npm ERR! JSON.parse "name": "materia...'
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 { "name": "material-kit-react", "version": "1.8.0", "description": "Material Kit React. Coded by Creative Tim", "private": true, "main": "dist/index.js", "dependencies": { "@material-ui/core": "4.3.2", "@material-ui/icons": "4.2.1", "classnames": "2.2.6", "history": "4.9.0", "moment": "2.24.0", "node-sass": "4.12.0", "nouislider": "14.0.2", "prop-types": "15.7.2", "react": "16.9.0", "react-datetime": "2.16.3", "react-dom": "16.9.0", "react-router-dom": "5.0.1", "react-scripts": "3.1.0", "react-slick": "0.25.2", "react-swipeable-views": "0.13.3" }, "devDependencies": { "@babel/cli": "7.5.5", "@babel/plugin-proposal-class-properties": "7.5.5", "@babel/preset-env": "7.5.5", "@babel/preset-react": "7.0.0", "eslint-config-prettier": "6.0.0", "eslint-plugin-prettier": "3.1.0", "eslint-plugin-react": "7.14.3", "gulp": "4.0.2", "gulp-append-prepend": "1.0.8", "prettier": "1.18.2" }, "optionalDependencies": { "typescript": "3.5.3" }, "scripts": { "start": "react-scripts start", "build": "react-scripts build && gulp licenses", "test": "react-scripts test --env=jsdom", "eject": "react-scripts eject", "lint:check": "eslint . --ext=js,jsx; exit 0", "lint:fix": "eslint . --ext=js,jsx --fix; exit 0", "install:clean": "rm -rf node_modules/ && rm -rf package-lock.json && npm install && npm start", "build-package-css": "node-sass src/assets/scss/material-kit-react.scss dist/material-kit-react.css", "build-package": "npm run build-package-css && babel src --out-dir dist", "compile-sass": "node-sass src/assets/scss/material-kit-react.scss src/assets/css/material-kit-react.css", "minify-sass": "node-sass src/assets/scss/material-kit-react.scss src/assets/css/material-kit-react.min.css --output-style compressed", "map-sass": "node-sass src/assets/scss/material-kit-react.scss src/assets/css/material-kit-react.css --source-map true" }, "browserslist": { "production": [ ">0.2%", "not dead", "not op_mini all" ], "development": [] } }
日志:
0 info it worked if it ends with ok
1 verbose cli [ '/home/singhanurag9080/.nvm/versions/node/v10.16.3/bin/node',
1 verbose cli '/home/singhanurag9080/.nvm/versions/node/v10.16.3/bin/npm',
1 verbose cli 'install',
1 verbose cli '-g' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
4 verbose npm-session 5398ffab8abd9470
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 silly fetchPackageMetaData error for file: Unexpected token { in JSON at position 27
8 timing stage:rollbackFailedOptional Completed in 1ms
9 timing stage:runTopLevelLifecycles Completed in 22ms
10 verbose stack SyntaxError: Unexpected token { in JSON at position 27
10 verbose stack at JSON.parse (<anonymous>)
10 verbose stack at module.exports (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/pacote/lib/util/read-json.js:14:15)
10 verbose stack at tryCatcher (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/util.js:16:23)
10 verbose stack at Promise._settlePromiseFromHandler (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:512:31)
10 verbose stack at Promise._settlePromise (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:569:18)
10 verbose stack at Promise._settlePromise0 (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:614:10)
10 verbose stack at Promise._settlePromises (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:694:18)
10 verbose stack at Promise._fulfill (/home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/promise.js:638:18)
10 verbose stack at /home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/bluebird/js/release/nodeback.js:42:21
10 verbose stack at /home/singhanurag9080/.nvm/versions/node/v10.16.3/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:90:16
10 verbose stack at FSReqWrap.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:53:3)
11 verbose cwd /home/singhanurag9080/Downloads/material-react/material-kit-react-master
12 verbose Linux 5.0.0-25-generic
13 verbose argv "/home/singhanurag9080/.nvm/versions/node/v10.16.3/bin/node" "/home/singhanurag9080/.nvm/versions/node/v10.16.3/bin/npm" "install" "-g"
14 verbose node v10.16.3
15 verbose npm v6.9.0
16 error Unexpected token { in JSON at position 27
17 verbose exit [ 1, true ]
谢谢。
答案 0 :(得分:0)
它认为package.json文件中存在无效字符。最好将文件发布。