我已经通过npm安装了不同的软件包来在React中运行一个简单的hello world应用程序(我是新手)。安装完成后,package.json
具有此格式。
{
"name": "test",
"version": "1.0.0",
"description": "test",
"main": "index.js"
},
"repository": {
"type": "git",
"url": "https://github.com/theo82"
},
"keywords": [
"test"
],
"author": "Theo Tziomakas",
"license": "ISC",
"dependencies": {
"react": "^15.4.2",
"react-dom": "^15.4.2",
"webpack": "^2.2.1"
}
}
在cmd(Windows 8.1)中运行 npm start 后,我收到此错误。
npm ERR! Unexpected token ',' at 6:4
npm ERR! },
npm ERR! ^
在各种答案中,人们通过使用干净缓存来解决这个问题
npm cache clean
然而,这对我不起作用:(。任何想法为什么会发生这种情况?
谢谢,
西奥。
答案 0 :(得分:0)
您的文件中存在语法错误。您还应该指定start
脚本应该执行的操作。例如,当您运行npm start
节点时,应执行index.js
文件
{
"name": "test",
"version": "1.0.0",
"description": "test",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [
"test"
],
"author": "",
"license": "ISC"
}

答案 1 :(得分:0)
package.json的语法有问题,在密钥{
timestamp: "2017-03-12T23:22:20.237+0000"
status: 400
error: "Bad Request"
exception: "org.springframework.validation.BindException"
errors: [1]
0: {
codes: [4]
0: "typeMismatch.userBean.dob"
1: "typeMismatch.dob"
2: "typeMismatch.java.util.Optional"
3: "typeMismatch"
arguments: [1]
0: {
codes: [2]
0: "userBean.dob"
1: "dob"
defaultMessage: "dob"
code: "dob"
}
defaultMessage: "Failed to convert property value of type 'java.lang.String' to required type 'java.util.Optional' for property 'dob'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@com.fasterxml.jackson.annotation.JsonFormat java.util.Date] for value '1988-10-07'; nested exception is java.lang.IllegalArgumentException"
objectName: "userBean"
field: "dob"
rejectedValue: "1988-10-07"
bindingFailure: true
code: "typeMismatch"
}
message: "Validation failed for object='userBean'. Error count: 1"
path: "/user"
}
}
main