我有一个 node 类型脚本项目,它使用了包括Express在内的几个第三方库.为了获得类型,我按照到处都能找到的说明安装@TYPE/EXPRESS模块作为dev依赖项.当我使用npm ci
安装我的包时,一切都运行得很好,但是当我try 遵循构建容器镜像的最佳实践并运行npm ci --only=production
时,构建失败并显示错误消息.
error TS7016: Could not find a declaration file for module 'express'. '/home/app/node_modules/express/index.js' implicitly has an 'any' type.
2.818 Try `npm i --save-dev @types/express` if it exists or add a new declaration (.d.ts) file containing `declare module 'express';`
这显然是因为它没有可用的类型库,但我在任何地方都看不到有人将@Types包作为产品依赖项安装.
此场景的最佳实践是什么?