简体   繁体   中英

Parcel Build Failed with error @parcel/resolver-default: Cannot load file '../../../../../css/main.css' in './src'

I use parcel@2.7.0. Everytime I load any external css or javascript file in my index.html, Parcel always fail to build with error:

Build failed.

@parcel/core: Failed to resolve './css/main.css' from './src/index.html' *

@parcel/resolver-default: Cannot load file '../../../../../css/main.css' in './src'.

Here is my Code

index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Parcel V2 Tutorial</title>
    <link rel="stylesheet" href="./css/main.css">
</head>
<body>
    <h1>Hello</h1>
</body>
</html>

main.css

body{
    background: cyan;
}

package.json

{
  "name": "parceltutorial",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "parcel src/index.html"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "@parcel/resolver-glob": "^2.7.0",
    "parcel": "^2.7.0"
  }
}

I also install @parcel/resolver-glob and here's my.parcelrc configuration

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

I tried to remove my.parcel-cache just like what other people say or do, but it still throw me that error. Thank you

Here's my file structure

have you tried using .module.css ? Reference: https://parceljs.org/languages/css/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM