TypeScript @types模块无法parsing对方
当我使用npm来安装类似于这样的TypeScript定义时
npm install --save @types/express
我无法使用已安装的模块,因为它们无法解决对方。 例如,@ types / express需要@ types / express-static-server-core,但是@types/express/index.d.ts
包含express-static-server-core
的相对path,所以无法parsing该模块:
node_modules/@types/express/index.d.ts(16,30): error TS2307: Cannot find module 'serve-static'. node_modules/@types/express/index.d.ts(17,23): error TS2307: Cannot find module 'express-serve-static-core'. node_modules/@types/serve-static/index.d.ts(15,26): error TS2307: Cannot find module 'express-serve-static-core'. node_modules/@types/serve-static/index.d.ts(16,20): error TS2307: Cannot find module 'mime'.
我该如何解决这个问题? 什么是安装TypeScript定义的最佳方法?
据我所知,typings已被弃用,所以我试图从@types安装types定义,然后使用
tsc --target ES5 --module commonjs index.ts
但它不工作。 我究竟做错了什么?