I have a my-dependency-package which is an NPM package that I'm using, which includes lib/utils/list-utils.
I have my-package which uses my-dependency-package as a dependency. When I try to build it, I get this error:
FAIL test/some-file.test.ts
● Test suite failed to run
Configuration error:
Could not locate module lib/utils/list-utils mapped as:
/some-path/my-package/lib/utils/list-utils.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^lib\/(.*)$/": "/some-path/my-package/lib/$1"
},
"resolver": null
}
at createNoMappedModuleFoundError (node_modules/jest-resolve/build/index.js:501:17)
at Object.<anonymous> (node_modules/@amzn/quicksilver-commons-cdk/lib/pipelines/quicksilver-pipeline.ts:4:1)
FAIL test/stack/order-aggregation-goldbox-lambda-stack.test.ts
● Test suite failed to run
Configuration error:
Could not locate module lib/utils/list-utils mapped as:
/some-path/my-package/lib/utils/list-utils.
Please check your configuration for these entries:
{
"moduleNameMapper": {
"/^lib\/(.*)$/": "/some-path/my-package/lib/$1"
},
"resolver": null
}
This is the package.json for my-package:
{
"name": "my-package",
"version": "1.0.0",
"scripts": {
"clean": "rm -rf ./build && rm -rf ./dist && rm -rf node_modules",
"test": "npm run lint && jest --passWithNoTests",
"posttest": "generate-coverage-data",
"prettier": "prettier bin/**/*.ts lib/*.ts lib/**/*.ts --write",
"lint": "eslint '**/*.{ts,js}'"
},
"dependencies": {
// some dependencies
"my-dependency-package": "*"
},
"devDependencies": {
// some devDependencies
},
"_moduleAliases": {
"lib": "lib"
}
}
And finally tsconfig.json:
{
"compilerOptions": {
"target": "ES2018",
"module": "commonjs",
"lib": ["es2016", "es2017.object", "es2017.string"],
"declaration": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"noImplicitThis": true,
"alwaysStrict": true,
"noUnusedLocals": false,
"noUnusedParameters": false,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": false,
"inlineSourceMap": true,
"inlineSources": true,
"experimentalDecorators": true,
"strictPropertyInitialization": false,
"typeRoots": ["./node_modules/@types"],
"baseUrl": "./",
"paths": {
"lib/*": ["lib/*"],
"test/*": ["test/*"],
}
},
"exclude": ["cdk.out"]
}
In case of need, I can share also same files for my-dependency-package.