Publishing node module in openForge
commands to push
- init git
- set origin
Npm command
- npm init/ npm init -y (to init the npm and set package.json file)
- code the index or the main file of the project (index or the main file)
- run npm run build
- npm login
- npm whoami *check the id is correct or not
- npm publish
Note
I had used typescript hence:
-
run npm i -D typescript in terminal after npm init
-
add tsconfig.json file with configurations and :-
- add "include": ["folder-name"] used to give the folde name to be compiled
- add "exclude": ["not-required-folder-names"] like node_modules, test files name
-
in package.json
- change *scripts* :-
- add "build":"tsc" for typescript
- add "prepare": "npm run build" to prepare the package file for publishing
- add at the end "files" : ["/lib/**/"] *for pushing only the lib file that was build after npm build on the npm registery
- or can create a new file .npmignore
- add "types" : " .d.ts", it tells where the decleration file is
- Note Don't forget to check the index,js file path