【发布时间】:2021-10-23 08:24:29
【问题描述】:
package.json 是使用 yarn cli 创建的。当我尝试构建它时它失败了。如果我删除 "main": "src/index.js" 它可以工作。 src/index.js 存在,但它现在是一个空文件。
我是否需要指定我的包的路径,或者为什么这会引发错误?将路径更改为错误消息中建议的路径也不起作用。
package.json
{
"name": "project",
"version": "0.1.0",
"description": "",
"main": "src/index.js",
"source": "src/index.html",
"browserslist": "supports es6-module",
"scripts": {
"start": "parcel --open chrome",
"build": "parcel build"
},
"repository": "",
"author": "",
"license": "MIT",
"dependencies": {
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0"
},
"devDependencies": {
"parcel": "^2.0.0-rc.0"
}
}
输出
$ parcel build
???? Build failed.
@parcel/namer-default: Target "main" declares an output file path of "src/index.js" which does not match the compiled bundle type "html".
.../project/package.json:5:11
4 | "description": "project",
> 5 | "main": "src/index.js",
> | ^^^^^^^^^^^^^^ Did you mean "src/index.html"?
6 | "source": "src/index.html",
7 | "scripts": {
???? Try changing the file extension of "main" in package.json.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
【问题讨论】:
-
据我所知,parcel see 的 main 作为其编译输出的目标,因此将其放在与源相同的目录中似乎不正确。应该是
"main": "dist/index.html" -
@Keith 给了我
@parcel/core: Unexpected output file type .html in target "main"
标签: javascript yarnpkg parceljs