我已经安装了版本号为“parcel”的parcel:“^2.0.0-rc.0”和我提到的json 当我尝试运行命令 npm start 我出现这样的错误 我想调用index.html页面,但它显示为文件扩展名必须是.js、.mjs或.cjs 我该如何解决这个问题?
"name": "receipe-book",
"version": "1.0.0",
"description": "you can get your favourite receipe here",
"main": "index.html",
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html"
},
"author": "Somu Nelavalli",
"license": "ISC",
"dependencies": {
"parcel": "^2.0.0-rc.0"
}```
Server running at http://localhost:1234
× Build failed.
@parcel/core: Unexpected output file type .html in target "main"
H:\Somu Pracatice\Javascript\complete-javascript-course-master\complete-javascript-course-master\18-forkify\starter\package.json:5:11
4 | "description": "you can get your favourite receipe here",
> 5 | "main": "index.html",
> | ^^^^^^^^^^^^ File extension must be .js, .mjs, or .cjs
6 | "scripts": {
7 | "start": "parcel index.html",
The "main" field is meant for libraries. If you meant to output a .html file, either remove the "main" field or choose a different target name.
Thanks in Advance
在 package.json 文件中将
main
重命名为 default
。
{
"version": "1.0.0",
"description": "",
"default": "dist/index.html"
}
只需将 main 重命名为默认即可正常工作
{ “版本”:“1.0.0”, “描述”:“你自己的”, “默认”:“index.html” }