I have an Angular 5 app that was previously running on Angular CLI 1.2.8 and everything was working great. After the upgrade to 1.3 (on my way to 1.5.4) there seems to be an issue with the external npm link libary we are using as I get an NullInjectorError: No provider for Http!
when visiting localhost:4200
When I add the HttpModule to the shared-lib module, the error goes away but I get additional provider errors. I am expecting the shared-lib to use the modules from the main app as it did before, not the shared-lib module. In this example the shared-lib has angular services that rely on HttpModule but the shard-lib does not import HttpModule. The main project I am using does import HttpModule.
My tsconfig.json:
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"baseUrl": "src",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"types": [ "node", "jasmine" ],
"lib": [
"es2016",
"dom"
],
"paths": {
"rxjs/*": [
"node_modules/rxjs/*"
],
"@angular/*": [
"node_modules/@angular/*"
]
}
}
}
my tsconfig.app.json:
{
"extends": "../tsconfig.json",
"compilerOptions": {
"outDir": "../out-tsc/app",
"module": "es2015",
"baseUrl": "",
"types": []
},
"include": [
"./**/*.ts",
"../node_modules/shared-lib/src/**/*.ts",
"../node_modules/shared-lib/index.ts",
"../node_modules/shared-lib/shared-lib.ts"
],
"exclude": [
"test.ts",
"**/*.spec.ts",
"../node_modules/shared-lib/**/*.spec.ts"
],
"typeRoots": [
"node_modules/@types"
],
"types": [ "node" ]
}
Update: I have found that after deleting the @angular folder in the shared-lib node_modules, the project works. I am not sure why they paths object in the tsconfig.json is not overriding the use of Angular to my project's node_modules only.