(节点:15867)警告:在循环依赖中访问模块导出的不存在属性“cat”

Posted

技术标签:

【中文标题】(节点:15867)警告:在循环依赖中访问模块导出的不存在属性“cat”【英文标题】:(node:15867) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency 【发布时间】:2021-08-21 22:58:43 【问题描述】:

每当我打开/保存任何文件时,ESLint 都会给我一个错误列表,例如:

(node:15900) Warning: Accessing non-existent property 'cat' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
(node:15900) Warning: Accessing non-existent property 'cd' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'chmod' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'cp' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'dirs' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'pushd' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'popd' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'echo' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'tempdir' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'pwd' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'exec' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'ls' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'find' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'grep' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'head' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'ln' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'mkdir' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'rm' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'mv' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'sed' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'set' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'sort' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'tail' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'test' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'to' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'toEnd' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'touch' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'uniq' of module exports inside circular dependency
(node:15900) Warning: Accessing non-existent property 'which' of module exports inside circular dependency

根据我对这个主题的阅读,我假设某个地方存在一个不存在的依赖关系,所以这里是 package.json 文件:


  "name": "advanced-react",
  "version": "1.0.0",
  "description": "Advanced React",
  "main": "lib/server.js",
  "repository": "jscomplete/advanced-react",
  "author": "Samer Buna",
  "license": "MIT",
  "scripts": 
    "dev": "pm2 start lib/server.js --watch --interpreter babel-node",
    "webpack": "webpack -wd"
  ,
  "babel": 
    "presets": [
      "react",
      "env",
      "stage-2"
    ]
  ,
  "devDependencies": 
    "babel-eslint": "^7.2.3",
    "eslint": "^3.19.0",
    "eslint-plugin-json": "^3.0.0",
    "eslint-plugin-react": "^6.10.3"
  ,
  "dependencies": 
    "babel-cli": "^6.24.1",
    "babel-loader": "^7.0.0",
    "babel-polyfill": "^6.23.0",
    "babel-preset-env": "^1.4.0",
    "babel-preset-react": "^6.24.1",
    "babel-preset-stage-2": "^6.24.1",
    "ejs": "^2.5.6",
    "express": "^4.15.2",
    "pm2": "^2.4.6",
    "react": "^15.5.4",
    "react-dom": "^15.5.4",
    "webpack": "^2.5.0"
  

还有我的 .eslintrc.js 文件:

module.exports = 
  "parser": 'babel-eslint',
  "env": 
    "browser": true,
    "commonjs": true,
    "es6": true,
    "node": true
  ,
  "extends": ["eslint:recommended", "plugin:react/recommended", 'plugin:json/recommended'],
  "parserOptions": 
    "ecmaFeatures": 
      "experimentalObjectRestSpread": true,
      "jsx": true
    ,
    "sourceType": "module"
  ,
  "plugins": [ "react" ],
  "rules": 
    "react/prop-types": ["off"],
    "indent": ["error", 2],
    "linebreak-style": ["error","unix"],
    "quotes": ["error","single"],
    "semi": ["error","always"],
    "no-console": ["warn",  "allow": ["info", "error"] ]
  
;

或者,here 是我从中提取文件的位置。我正在运行节点 v14.10.0。有谁知道我为什么会收到错误消息?

【问题讨论】:

【参考方案1】:

显然,您需要将 nodejs 降级到 v12。或者你可以使用node --no-warnings

【讨论】:

以上是关于(节点:15867)警告:在循环依赖中访问模块导出的不存在属性“cat”的主要内容,如果未能解决你的问题,请参考以下文章

错误:警告:在循环依赖中访问模块导出的不存在属性“findOne”

在循环依赖中访问模块导出的不存在的属性“padLevels”

Yeoman - 在循环依赖中访问模块导出的不存在属性____

节点模块导出,访问不存在的属性错误,Jasmine

Spring Boot (kotlin) 循环依赖

节点模块未安装