sample-library-qhklm
v0.0.1
Published
1. Create a new NestJS project using NestJS CLI 2. Create a new file called `index.ts` in the `src` folder 3. Then add the following code to the `index.ts` file
Downloads
4
Readme
Sample NPM Library using NestJS
Process
- Create a new NestJS project using NestJS CLI
- Create a new file called
index.tsin thesrcfolder - Then add the following code to the
index.tsfile
export { WhatevertheServiceYouWant } from './theLocationForTheService';Example in this application
export { AppService } from './app.service';- Before building the project, you need to add the following code to the
package.jsonfile. (Replace the dist if you have a different output folder)
"main": "dist/index.js",Optional (For Local Usage)---
- If you want to use this in a local project, you can use the following command to link the project to your local project and make it available for globally for use.
npm link- How to use the library in your project
import { WhatevertheServiceYouWant } from 'name-of-the-package-as-in-package.json-under-"name:" attribute';Example in this application
import { AppService } from 'sample-library';- Finally build the project using the following command
npm run buildNow your NestJS based NPM library is ready to use.
