javascript - @包裹/核心: Failed to resolve 'index.html' Getting this error

标签 javascript parceljs

我的 package.json 文件

{
"name": "aiky",
"version": "1.0.0",
"description": "Recipe application",
"default": "index.html",
"scripts": {
  "start": "parcel index.html",
  "build": "parcel build index.html --dist-dir ./dist"
},
"author": "Akash Kesharwani",
"license": "ISC",
"devDependencies": {
  "@parcel/resolver-glob": "^2.0.0-rc.0",
  "@parcel/transformer-image": "^2.0.0-rc.0",
  "@parcel/transformer-sass": "^2.0.0-rc.0",
  "parcel": "^2.0.0-rc.0",
  "sass": "^1.26.10"
},
"dependencies": {
  "core-js": "^3.6.5",
  "fractional": "^1.0.0",
  "regenerator-runtime": "^0.13.7"
},
"main": "index.js"
}

我在互联网上找不到解决方案。 在此之前,我收到此错误

@parcel/core: Failed to resolve 'src/img/test-1.jpg' from './index.html'

@parcel/resolver-default: Cannot load file './src/img/test-1.jpg' in './'.

因此,我安装了 @parcel/resolver-glob 并在根目录中添加了 .parcelrc 以及此文本

{
"extends": "@parcel/config-default",
"resolvers": ["@parcel/resolver-glob"]
}

最佳答案

Parcel documentation来看不是很明显,但您需要通过将文字字符串 "..." 添加到解析器数组来包含默认解析器。

The "..." syntax can be used to extend the default resolvers. This allows you to override the resolution for certain dependencies, but fall back to the default for others. Generally, you'll want to add your custom resolvers before running the default ones.

{
  "extends": "@parcel/config-default",
  "resolvers": ["@parcel/resolver-glob", "..."]
                                         ^^^^^
}

关于javascript - @包裹/核心: Failed to resolve 'index.html' Getting this error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69823944/

相关文章:

javascript - 在不同情况下使用 Passport.js 更改和保存重定向

javascript - Knockout.js 通过 ajax 调用将项目添加到 foreach

JavaScript 在函数 'class' 包装器之间进行 promise

javascript - 我怎样才能转换这个对象

cypress - 如何在使用 ParcelJS 构建的 Cypress 测试中使用带有绝对路径的导入?

javascript - chrome 72 更改了 sourcemap 行为

javascript - 动画 ->向左滑动不工作jQuery

javascript - Gulp 4 browserSync 与 Pug 和 Parceljs 任务并行

javascript - Font Awesome 5 中的 dom.i2svg() 不工作

node.js - 同时支持 Webpack、Parcel 和 Rollup 的最佳方法?