我确实在我的依赖项中看到了它,并且我再次运行:npm I chai chai.as.promise事件,但仍然看不到模型。谢谢你的帮助。
后:松露试验
Compiling your contracts...
===========================
> Compiling ./src/contracts/Token.sol
> Artifacts written to /var/folders/1v/9ln82rd97dqghgyk_7krrwtr0000gn/T/test--22208-ZPVpGBs8ds6D
> Compiled successfully using:
- solc: 0.5.16+commit.9c3226ce.Emscripten.clang
Error: Cannot find module 'chai.as.promised'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (/Users/davell/my-blockchain-site/test/Token.test.js:9:21)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at loader (/Users/davell/my-blockchain-site/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/davell/my-blockchain-site/node_modules/babel-register/lib/node.js:154:7)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /usr/local/lib/node_modules/truffle/node_modules/mocha/lib/mocha.js:390:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles
我运行:npm I chai chai.as.promise
my-blockchain-site git:(master) ✗ npm i chai chai-as-promised
npm WARN @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.15.4 requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/plugin-proposal-class-static-block@7.15.4 requires a peer of @babel/core@^7.12.0 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.5.2 requires a peer of jquery@1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap@4.5.2 requires a peer of popper.js@^1.16.1 but none is installed. You must install peer dependencies yourself.
npm WARN postcss-browser-comments@3.0.0 requires a peer of browserslist@^4 but none is installed. You must install peer dependencies yourself.
npm WARN react-apexcharts@1.3.7 requires a peer of apexcharts@^3.18.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-scripts@3.4.3 requires a peer of typescript@^3.2.1 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of node-sass@^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of sass@^1.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN sass-loader@8.0.2 requires a peer of fibers@>= 3.1.0 but none is installed. You must install peer dependencies yourself.
npm WARN tsutils@3.21.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
+ chai-as-promised@7.1.1
+ chai@4.3.4
updated 2 packages and audited 2401 packages in 11.389s
found 119 vulnerabilities (9 low, 49 moderate, 60 high, 1 critical)
run `npm audit fix` to fix them, or `npm audit` for details
➜ my-blockchain-site git:(master) ✗
但仍然找不到它谢谢你
有同样的问题,直到我发现在测试脚本中我把它拼错了:require("chai-as-promise")而不是require("chai-as-promised")。
检查语法
我遇到了同样的问题,但我安装了这个npm install chai-as-promise从chai-as-promised