This is a demonstration to publish npm package publicly and use it.
- https://github.com/DonzTea/react-widget repo demonstrating how to publish a react component as public npm package.
- https://github.com/DonzTea/react-use-widget (this repo) demonstrating how to use published npm package.
git clone [email protected]:DonzTea/react-widget.git
git clone [email protected]:DonzTea/react-use-widget.git
- on react-widget, set
"name": "project-name"
inpackage.json
- on react-widget, set
"main": "./src/index.tsx"
inpackage.json
- on react-widget, run
npm link
- on react-use-widget, run
npm link <project-name>
- on react-use-widget, import the package then use it
- on react-use-widget, run
npm unlink --no-save <project-name>
- on react-widget, run
npm unlink --no-save <project-name>
- on react-widget, run
npm login
- on react-widget, remove
"private": true
frompackage.json
- on react-widget, run
npm publish
- on react-widget, run
npm login
- on react-widget, remove
"private": true
frompackage.json
- on react-widget, change
"name": "project-name"
inpackage.json
to"name": โ@username/project-name"
- on react-widget, run
npm publish --access=public