首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >参数'filename‘必须是文件URL对象、文件URL字符串或绝对路径字符串。接收'http://localhost/eslintrc.cjs‘’

参数'filename‘必须是文件URL对象、文件URL字符串或绝对路径字符串。接收'http://localhost/eslintrc.cjs‘’
EN

Stack Overflow用户
提问于 2022-02-02 18:31:18
回答 1查看 1.7K关注 0票数 1

Vue 3 JS中运行单元测试时,我会收到以下错误。我假设底层包中存在不兼容性,但我不知道如何找到它并修复它。

代码语言:javascript
复制
$ vue-cli-service test:unit
  [                         ] 0% () WEBPACK  Compiling...

  [======================== ] 95% (emitting)

 ERROR  Failed to compile with 2 errors

The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'http://localhost/eslintrc.cjs'

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
  Error: Child compilation failed:
  The argument 'filename' must be a file URL object, file URL string, or absolute path string. Received 'http://localhost/eslintrc.cjs'
  
  - child-compiler.js:169 
    [web-frontend]/[html-webpack-plugin]/lib/child-compiler.js:169:18
  
  - Compiler.js:564 
    [web-frontend]/[webpack]/lib/Compiler.js:564:11
  
  - Compiler.js:1183 
    [web-frontend]/[webpack]/lib/Compiler.js:1183:17
  
  
  - task_queues:96 processTicksAndRejections
    node:internal/process/task_queues:96:5
  

  [=========================] 99% (done) WEBPACK  Failed to compile with 2 error(s)

我的package.json

代码语言:javascript
复制
{
  "name": "web-frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "test:e2e": "vue-cli-service test:e2e",
    "lint": "vue-cli-service lint",
  },
  "dependencies": {
    "@vue/server-renderer": "^3.0.4",
    "Buffer": "^0.0.0",
    "axios": "^0.25.0",
    "core-js": "^3.19.0",
    "https-browserify": "^1.0.0",
    "js-yaml": "^4.1.0",
    "openapi-client-axios": "^4.4.9",
    "process": "^0.11.10",
    "stream-browserify": "^3.0.0",
    "stream-http": "^3.2.0",
    "util": "^0.12.4",
    "vue": "^3.2.20",
    "vue-meta": "^3.0.0-alpha.9",
    "vue-router": "^4.0.12",
    "vuex": "^4.0.2",
    "vuex-module-decorators": "^2.0.0",
    "workbox-background-sync": "^6.4.2",
    "workbox-broadcast-update": "^6.4.2",
    "workbox-build": "^6.4.2",
    "workbox-cacheable-response": "^6.4.2",
    "workbox-cli": "^6.4.2",
    "workbox-core": "^6.4.2",
    "workbox-expiration": "^6.4.2",
    "workbox-google-analytics": "^6.4.2",
    "workbox-navigation-preload": "^6.4.2",
    "workbox-precaching": "^6.4.2",
    "workbox-range-requests": "^6.4.2",
    "workbox-routing": "^6.4.2",
    "workbox-strategies": "^6.4.2",
    "workbox-streams": "^6.4.2",
    "workbox-sw": "^6.4.2",
    "workbox-webpack-plugin": "^6.4.2",
    "workbox-window": "^6.4.2"
  },
  "devDependencies": {
    "@babel/core": "^7.15.8",
    "@types/chai": "^4.2.22",
    "@types/mocha": "^9.0.0",
    "@typescript-eslint/eslint-plugin": "^5.2.0",
    "@typescript-eslint/parser": "^5.2.0",
    "@vue/cli-plugin-babel": "^4.5.15",
    "@vue/cli-plugin-e2e-cypress": "~5.0.0-rc.2",
    "@vue/cli-plugin-eslint": "~5.0.0-rc.2",
    "@vue/cli-plugin-router": "~5.0.0-rc.2",
    "@vue/cli-plugin-typescript": "~5.0.0-rc.2",
    "@vue/cli-plugin-unit-mocha": "~5.0.0-rc.2",
    "@vue/cli-plugin-vuex": "~5.0.0-rc.2",
    "@vue/cli-service": "^5.0.0-rc.2",
    "@vue/compiler-sfc": "^3.0.0-beta.14",
    "@vue/eslint-config-airbnb": "^6.0.0",
    "@vue/eslint-config-typescript": "^10.0.0",
    "@vue/test-utils": "^2.0.0-rc.18",
    "chai": "^4.1.2",
    "cypress": "*",
    "eslint": "^8.8.0",
    "eslint-import-resolver-typescript": "^2.5.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-vue": "^8.1.1",
    "eslint-plugin-vuejs-accessibility": "^1.1.0",
    "sass": "^1.26.5",
    "sass-loader": "^12.3.0",
    "typescript": "~4.5.2",
    "webpack": "^5.60.0"
  },
  "peerDependencies": {
    "webpack": "^4.46.0"
  }
}
EN

回答 1

Stack Overflow用户

发布于 2022-02-02 19:27:58

经过一些尝试和错误之后,将eslint恢复为"eslint": "^7.17.0",解决了这个问题。但是,我想要一个更好的解释,因为我不明白为什么会发生这种情况,究竟是什么库导致了这种情况(所以我不知道在哪里提交问题),也不知道如何不被困在eslint上。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70960942

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档