如何解决NPM PATCEL中的构建失败错误

问题描述 投票:0回答:0

我如何修复?

服务器在http:// localhost上运行:1234 🚨构建失败

@@parcel/core:意外的输出文件类型.html目标中 “主要”

/用户/nasersobhan/desktop/coding/完整的JavaScript课程udemy/possectim-javascript-course-master/18 forkify/starter/packager.json:5:11 4 | “描述”:“食谱应用程序”,

5| “ main”:“ index.html”, | ^^^^^^^^^^^^^文件扩展名为.js,.mjs或.cjs 6 | “脚本”:{ 7 | “ start”:“包裹index.html”,

💡“主”字段用于图书馆。如果你的意思 要输出.html文件,请删除“主”字段 或选择其他目标名称。 📝了解更多:

https://parceljs.org/features/targets/#library-targets

在这里修复它: 删除主字段: 构建库时,包装中的主字段应指向一个JavaScript文件(例如.js,.mjs或.cjs)。由于您正在使用Web应用程序并使用index.html作为入口点,因此应完全删除主字段。 您的软件包。JSON应该看起来像这样:

json { "name": "your-project-name", "version": "1.0.0", "description": "Your project description", "scripts": { "start": "parcel index.html", "build": "parcel build index.html", "test": "jest" }, "license": "ISC", "devDependencies": { "parcel": "^2.0.0" }, "dependencies": { "react": "^19.0.0", "react-dom": "^19.0.0", "react-router-dom": "^6.29.0" } }

npm parcel
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.