[英]Unexpected output file type .html in target "main" (^^^^^^^^^^^^ File extension must be .js, .mjs, or .cjs)
i had installed parcel with version number "parcel": "^2.0.0-rc.0" and json i mentioned like this when i try to run the command npm start i am error like this i want to call index.html page but it is showing like File extension must be .js, .mjs, or .cjs How can i solve this issue ?我已经安装了版本号为“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
The source of that error is the "main": "index.html"
field in your package.json
.该错误的来源是
package.json
中的"main": "index.html"
字段。 According to the documentation , this field is intended to be used by library projects (eg npm packages that are consumed by others) - it tells parcel to output a commonjs JavaScript bundle at that location, which doesn't make sense for an html file.根据文档,该字段旨在供库项目(例如,其他人使用的 npm 包)使用 - 它告诉 parcel 在该位置输出一个 commonjs JavaScript 包,这对于 html 文件没有意义。
Since it doesn't appear that you are developing a library, you can simply remove "main": "index.html"
, and it should work fine ( see migration docs ).由于您似乎没有在开发库,因此您可以简单地删除
"main": "index.html"
,它应该可以正常工作( 请参阅迁移文档)。
To specify the ouput directory for non-library projects, use the --dist-dir
cli parameter instead ( see docs ).要为非库项目指定输出目录,请改用
--dist-dir
cli 参数(请参阅文档)。
Rename main
to default
in the package.json file.在 package.json 文件中将
main
重命名为default
。
{
"version": "1.0.0",
"description": "",
"default": "dist/index.html"
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.