package.json是由纱线制成的。当我试图建造它的时候它就失败了。如果我删除"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.
https://stackoverflow.com/questions/68884914
复制相似问题