Our custom npm logging module, which is built using TypeScript and relies on the pino
library, encounters errors when being imported into an application:
Error: node_modules/@scope/logging/lib/index.d.ts(1,23): error TS2688: 'pino' type definition file not found
Error: node_modules/@scope/logging/lib/index.d.ts(2,23): error TS7016: Declaration file for 'pino' module not found. Implicitly using type 'any'. Consider `npm install @types/pino` or create a new declaration (.d.ts) file with `declare module 'pino';`
In the package.json file:
{
"name": "@scope/logging",
"version": "1.0.0",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"dependencies": {
"pino": "4.16.1"
},
"devDependencies": {
"@types/pino": "4.7.1",
"typescript": "2.8.3"
}
}
The tsconfig.json configuration:
{
"compileOnSave": true,
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"inlineSources": true,
"inlineSourceMap": true,
"declaration": true,
"outDir": "lib",
"baseUrl": ".",
"typeRoots": ["node_modules/@types"],
"paths": {
"*": [
"node_modules/*",
"src/types/*"
]
},
...
}
...
...
...
...
...