简体   繁体   English

@parcel/core: 无法解析“index.html”得到这个错误

[英]@parcel/core: Failed to resolve 'index.html' Getting this error

My package.json file我的 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"
}

I can't find the solution over the internet.我无法通过互联网找到解决方案。 Before this, I was getting this error在此之前,我收到此错误

@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 './'.

So, I installed @parcel/resolver-glob and also added .parcelrc in root with this text所以,我安装了 @parcel/resolver-glob 并在 root 中添加了.parcelrc与此文本

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

It's not very obvious from the Parcel documentation , but you will need to include the default resolvers by adding the literal string "..." to the resolvers array.Parcel 文档中它不是很明显,但是您需要通过将文字字符串"..."到解析器数组来包含默认解析器。

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", "..."]
                                         ^^^^^
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 通过启动外部文件 index.html I 忽略主文件,服务器在包裹中运行错误,但它也不起作用(构建失败) - Server running error in parcel by starting the external file index.html I Ignoring the main but it also doesn't work(Build Failed) 无法解决index.html中的错误 - Unable to resolve error in index.html Parcel Bundler:本地主机上一切正常,但 Dist 上的 index.html 显示错误 - Parcel Bundler: Everything is okay on localhost but The index.html on Dist is showing Error 使用“parcel index.html”后外部 .js 不起作用 - external .js not working after using “parcel index.html” npm run dev 和 parcel index.html 的区别 - Difference between npm run dev and parcel index.html 引导程序入门损坏index.html - Bootstrap getting started broken index.html 在当地工作。 但是当我使用包裹 index.html 它不是 - Locally working. But when i use parcel index.html it's not parcel serve 返回 index.html 用于 SourceMap 请求和不存在的 url - parcel serve returns index.html for SourceMap requests and non existent urls Karma错误:[$ injector:modulerr]由于以下原因而无法实例化模块:(Index.html正常运行) - Karma Error: [$injector:modulerr] Failed to instantiate module due to: (Index.html is working perfectly) 在resolve和根index.html文件中访问$ rootScope - access $rootScope in resolve and root index.html file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM