@manaskp/mynpmpackage
v1.0.2
Published
1. Initialize npm ``` npm init -y ```
Downloads
5
Readme
- Initialize npm
npm init -y
- Initialize typescript
npx tsc --init
Complete your code
Update in
package.json
- Update
name
as@manaskp/mymodule
- Update
version
every time you publish your module - Update
main
to your directory. In my case I use typescript so, I have to enter the.js
. Sodist/index.js
- Build typescript code
- First change
rootDir = 'src'
andoutDir = 'dist'
intsconfig.json
- Update
declaration = true
in this file. So that it will generateindex.d.ts
. This file is for type definition - THen build the code
tsc -b
- Then login to npm
npm login
- Then publish it to public
npm publish --access=public
- Create a
.npmignore
file and putsrc/
in it.
npx npmignore
- Pack the published file, and it will generate
.zip
file
npm pack
- Then import in ur needed place, by
npm i {npm module name}