Answer the question
In order to leave comments, you need to log in
How to import files from a library?
I am doing a project on nestjs in the form of 2 services. Both services use the same code, I decided to move it to a separate library.
As a result, I created a ts-client package, uploaded it to git and installed it as "npm install git+ https://github.com/user/ts-client.git ".
Installed without problems, but the import does not work:
Error: Cannot find module 'ts-client/src/middleware/set-user-agent.middleware'
{
"name": "ts-client",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@nestjs/axios": "^0.0.3",
"@nestjs/common": "^8.2.2",
"@types/accept-language-parser": "^1.5.3",
"accept-language-parser": "^1.5.0"
},
"devDependencies": {
"typeorm": "^0.2.41"
}
}
import {Injectable, NestMiddleware} from '@nestjs/common';
@Injectable()
export class SetUserAgentMiddleware implements NestMiddleware {
use(req: any, res: any, next: () => void) {
next()
}
}
Answer the question
In order to leave comments, you need to log in
Try to take advantage of what Nest itself offers. https://docs.nestjs.com/cli/libraries
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question