I am working on a project that is split up between multiple angular projects. I then have some services that are used in each project. Is there a way for me to load these in my project? I am getting errors when I try to do so.
/root
/project-1
/angular.json
/tsconfig.json
/project-2
/angular.json
/tsconfig.json
/utilities
/src
/auth.service.ts
/s3.service.ts
/lambda.service.ts
I have this in the root of the the angular projects tsconfig.json
file (project-1, project-2):
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@utilities/*": [
"../utilities/src/*"
]
}
}
}
when I run npm start
in project-1
, I get the following error(s):
Error: ../utilities/node_modules/buffer-equal-constant-time/index.js
Module not found: Error: Can't resolve 'buffer' in 'C:\projects\utilities\node_modules\buffer-equal-constant-time'
// Same error repeated for different modules...
In my utilities/package.json
{
"dependencies": {
"@angular/core": "^11.0.5",
"@aws-sdk/client-cognito-identity": "^3.0.0",
"@aws-sdk/client-lambda": "^3.0.0",
"@aws-sdk/credential-provider-cognito-identity": "^3.0.0",
"jsonwebtoken": "^8.5.1",
"rxjs": "^6.6.3",
"tslib": "^2.0.0"
},
}
I have figured out one way to do this. In the utilities
folder make it a link npm link
. Then in the project-1
folder link to the project npm link utilities
.
I then had to add some paths and includes in the tsconfig.json
for references:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@utilities/*": [
"node_modules/utilities/src/*"
]
}
},
"include": [
"node_modules/utilities/src/**/*.ts"
]
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With