gpt4 book ai didi

webpack-2 - nodejs react:命令yarn build时package.json文件中的构建脚本不起作用

转载 作者:行者123 更新时间:2023-12-01 13:32:02 24 4
gpt4 key购买 nike

在package.json上进行以下编辑后,当我运行yarn build命令时,在linux和Windows上:

{  
"name": "chatastrophe",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"scripts": {
"build": "node_modules/.bin/webpack",
' },
"dependencies": {
"react": "15.6.1",
"react-dom": "15.6.1",
"webpack": "3.5.4",
}
}

我不断收到此错误:

错误发生意外错误:
“C:\ Users \ Richard \ Desktop \ chatastrophe \ package.json:意外
JSON中位于位置175的 token }“。信息如果您认为这是一个错误,
请使用提供的信息打开错误报告
“C:\ Users \ Richard \ Desktop \ chatastrophe \ yarn-error.log”。

该错误的更详细版本如下(当我使用npm代替yarn时)
npm ERR! file C:\Users\Richard\Desktop\chatastrophe\package.json
npm ERR! code EJSONPARSE
npm ERR! Failed to parse json
npm ERR! Unexpected token } in JSON at position 175 while parsing near '...webpack",
npm ERR! },
npm ERR! "dependen...'
npm ERR! File: C:\Users\Richard\Desktop\chatastrophe\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! Tell the package author to fix their package.json file. JSON.parse

谁能帮帮我。提前致谢。

最佳答案

您的package.json构建脚本是无效的JSON,逗号后有一个单引号。试试这个:

 {
"name": "chatastrophe",
"version": "1.0.0", "main": "index.js", "license": "MIT",
"scripts": {
"build": "node_modules/.bin/webpack"
},
"dependencies": {
"react": "15.6.1",
"react-dom": "15.6.1", "webpack": "3.5.4",
}
}

关于webpack-2 - nodejs react:命令yarn build时package.json文件中的构建脚本不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49245070/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com