Parcel Build 抛出错误 [错误:打开目录时出错]

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

我是 Parcel 和 Node 包的新手,我正在尝试使用 Parcel ad gh-pages 将我的项目部署到 github 页面。我在

package.json

创建了以下脚本

"build:parcel": "parcel build ./src/index.html"

问题是当它完成构建时,抛出错误[错误:打开目录时出错]


✨ Built in 327ms

dist\index.html              3.04 KB    3.02s
dist\index.955ccd1a.css    183.28 KB    103ms
dist\index.3e71ab34.js       2.26 KB    190ms
dist\index.607dc078.js     173.57 KB    2.25s
[Error: Error opening directory]

有时,即使我运行脚本

"start": "parcel ./src/index.html"
parcel也不会创建dist文件夹。

我的完整

package.json

{
  "name": "herosacai",
  "version": "1.0.0",
  "homepage": "https://venifeitosa.github.io/herosacai/",
  "description": "",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "parcel ./src/index.html",
    "build:parcel": "parcel build ./src/index.html",
    "clear:wind": "rd /s/q dist",
    "build": "npm run clear:wind && npm run build:parcel",
    "predeploy": "npm run build",
    "deploy": "gh-pages -d dist"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "bootstrap": "^5.2.0",
    "jquery": "^3.6.0"
  },
  "devDependencies": {
    "parcel": "^2.6.2"
  }
}
javascript parcel
2个回答
1
投票

我通过在包裹脚本中添加参数

--no-cache
解决了这个问题

之前:

"start": "parcel ./src/index.html"

"build:parcel": "parcel build ./src/index.html"

之后:

"start": "parcel ./src/index.html --no-cache"

"build:parcel": "parcel build ./src/index.html --no-cache"

0
投票

清除包裹缓存并像以前一样继续。

rm -rf .parcel-cache
© www.soinside.com 2019 - 2024. All rights reserved.