npm @types软件包的typesglobalDevDependencies的等价性是什么?
我想升级一个tsc@1.8项目到TSC @ 2,并在我的工具链中进行沟通types。
这对于来自typings.json
这些依赖关系的常见依赖不是问题:
"dependencies": { "bluebird": "registry:npm/bluebird#3.3.4+20160515010139", "lodash": "registry:npm/lodash#4.0.0+20160416211519", "mime": "registry:npm/mime#1.3.0+20160423043021" }
我可以很容易地安装通过
npm i @types/bluebird @types/lodass @types/mime
然而,我的globalDevDependencies
也有一些globalDevDependencies
于我的testing设置:
"globalDevDependencies": { "mocha": "registry:dt/mocha#2.2.5+20160317120654" }
我的第一个尝试是:
npm install @types/mocha --save-dev
然而,现在呢,他们抱怨说,它并不了解it
describe
的mocha
function。
tests/unit/HelloServiceTest.ts(4,1): error TS2304: Cannot find name 'describe'. tests/unit/HelloServiceTest.ts(5,5): error TS2304: Cannot find name 'it'. tests/unit/HelloServiceTest.ts(10,5): error TS2304: Cannot find name 'it'.
我错误地认为在全球安装这些解决scheme可能会解决这个问题:
npm i @types/mocha -g
我也遇到了这个问题 ,解决scheme是不排除tsconfig.json
的types文件夹:
"exclude": [ "node_modules", "!node_modules/@types" ]
但它也没有为我工作,抛出同样的错误。
最后,我不知道如何达到globalDevDependencies
和globalDependencies
效果,我只想使用npm
和@types/*
包而不是@types/*
。
这个线程指出了我正确的方向,因为我必须将types添加到tsconfig.json
:
{ "compilerOptions": { "target": "ES6", "types": ["node", "mocha", "chai"], ... }
types选项也有一个详细的文档。
- Node.js SyntaxError:ANTLR4 JavaScript Lexer中的意外标识符“boolean”
- 在全新的快递项目doctype 5`上出现错误,您现在必须使用`doctype html`
- Javascript node.js ORM,遵循数据映射器模式
- BLE GATT:为什么在整数types中存储小数?
- 最稳定的方式将一个32位无符号整数转换为大端字节数组?
- 将自定义types的数组传递给来自node-pg和SQL注入的postgres函数
- node.js中的头文件 – 套接口io资源解释为脚本,但是以MIMEtypes传递text / plain:
- browser.d.ts依赖Edge Web扩展API browser.runtime。* in typescript
- 在Node.js中,读取一个.html文件的目录并在其中search元素属性?