我已经尝试了所有我知道的方法,但以下问题无法解决,所以我想征求您的意见。先谢谢你了。
直到昨天,应用程序运行良好,然后我添加了一些函数和测试用例,我没有添加任何新的依赖项(我已经通过检查Github上的提交历史确认了这一点)。测试运行良好,然后我运行npm run dev
或npm start
,我有以下问题报告typerror从chai(我仍然可以运行测试的npm run test
).
我尝试过的事情:
- search 'TypeError:addProperty不是一个函数'在谷歌上,没有什么
1.按承诺重新安装chai和chai
1.删除node_modules并通过运行npm i
重新安装所有依赖项
1.从18升级节点。7.0到18.16。0
我现在该怎么办?有线索吗
~~/node_modules/chai/lib/chai/assertion.js:94
util.addProperty(this.prototype, name, fn);
^
TypeError: util.addProperty is not a function
at Assertion.addProperty (~~/node_modules/chai/lib/chai/assertion.js:94:10)
at ~~/WechatBot_Server/node_modules/chai/lib/chai/core/assertions.js:48:15
at Array.forEach (<anonymous>)
at module.exports (~~/node_modules/chai/lib/chai/core/assertions.js:47:46)
at exports.use
(~~/node_modules/chai/lib/chai.js:39:5)
at Object.<anonymous>
(~~/node_modules/chai/lib/chai.js:71:9)
at Module._compile (node:internal/modules/cjs/loader:1254:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
Node.js v18.16.0
我的包。json:
"scripts": {
"start": "node ./bin/www.js",
"dev": "NODE_ENV=dev nodemon ./bin/www.js",
"debug": "NODE_ENV=dev node --inspect ./bin/www.js",
"test": "NODE_ENV=test mocha --recursive --exit --timeout 20000",
"test:unit": "NODE_ENV=test mocha test/unit --recursive --exit --timeout 20000",
"test:integration": "NODE_ENV=test mocha test/integration --recursive --exit --timeout 20000"
},
"dependencies": {
"app-root-path": "^3.1.0",
"axios": "^1.3.5",
"bcrypt": "^5.1.0",
"chatgpt": "^5.1.3",
"cookie-parser": "~1.4.4",
"cors": "^2.8.5",
"crypto": "^1.0.1",
"debug": "~2.6.9",
"dotenv": "^16.0.3",
"express": "~4.16.1",
"handlebars": "^4.7.7",
"hirestime": "^7.0.3",
"http-errors": "~1.6.3",
"ioredis": "^5.3.2",
"jade": "~1.11.0",
"jsonwebtoken": "^9.0.0",
"lodash": "^4.17.21",
"mint-filter": "^4.0.2",
"mongoose": "^7.0.0",
"morgan": "~1.9.1",
"nodemailer": "^6.9.1",
"nodemon": "^2.0.21",
"openai": "^3.2.1",
"path": "^0.12.7",
"readline": "^1.3.0",
"redis": "^4.6.4",
"redlock": "^5.0.0-beta.2",
"remark": "^14.0.2",
"strip-markdown": "^5.0.0",
"supertest": "^6.3.3",
"swagger-ui-express": "^4.6.2",
"winston": "^3.8.2",
"winston-mongodb": "^5.1.1"
},
"devDependencies": {
"chai": "^4.3.7",
"chai-as-promised": "^7.1.1",
"eslint": "^8.34.0",
"eslint-config-airbnb": "^19.0.4",
"eslint-plugin-import": "^2.27.5",
"eslint-plugin-jsx-a11y": "^6.7.1",
"eslint-plugin-react": "^7.32.2",
"eslint-plugin-react-hooks": "^4.6.0"
}
1条答案
按热度按时间j2cgzkjk1#
好了,我终于找到了为什么会这样:
在其中一个非测试文件中,自动完成添加以下import
import { expectTypes } from 'chai/lib/chai/utils/index.js'
这就是为什么我运行
npm start
,它抛出了与chai
相关的错误(因为chai
只在测试中使用)我怎么知道
chai
文件夹,然后它抛出相同的错误chai
很久以前作为一个全局依赖,我然后卸载了chai
在全局依赖npm start
,它显示了我不想添加的导入