我正在尝试在当前的 typescript 项目中设置 mocha 和 chai。
我正在浏览下面的页面来实现相同的功能:-
$ typings install dt~mocha --global --save
我在 Ubuntu 中运行上述命令时遇到错误:-
<小时/>typings ERR! message Unable to find "dt~mocha" ("npm") in the registry. Did you want to try searching another source? Also, if you want to contribute these typings, please help us: https://github.com/typings/registry
typings ERR! caused by https://api.typings.org/entries/npm/dt~mocha/versions/latest responded with 404, expected it to equal 200
typings ERR! cwd /home/abhishek/Desktop/TypeScript/automation/jasmine
typings ERR! system Linux 3.19.0-47-generic
typings ERR! command "/usr/local/bin/node" "/usr/local/bin/typings" "install" "dt~mocha" "--global" "--save"
typings ERR! node -v v7.7.3
typings ERR! typings -v 0.8.1
typings ERR! If you need help, you may report this error at:
typings ERR! <https://github.com/typings/typings/issues>
<小时/>
我尝试在互联网上搜索。另外,我尝试了一些方法,但都失败了。
关于如何解决我的问题有什么想法吗?
最佳答案
我浏览了该页面,而不是运行以下命令:-
$ typings install dt~mocha --global --save
$ typings install npm~chai --save
我看到您共享的页面上有一个可以使用的命令:-
现在有另一种方法可以添加类型定义,来自 TypeScript 2.0,因此我们也可以使用它来代替上面提到的打字方法。此方法不依赖于输入 npm 包或模块。要使用它,请键入以下命令:
$ npm install @types/chai @types/mocha --save-dev
我按照其余步骤操作,它成功了!!!
我知道这可能不是最终的解决方案,但应该可以。
关于node.js - 在注册表中找不到 "dt~mocha"("npm"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46054367/