npmcounterpackage
v0.1.0
Published
Developing a sample npm package from react components
Downloads
1
Readme
npm_Counter_React_Component
Whether you're a seasoned developer or just getting started, this repository will walk you through all the necessary steps to share your React component with the world as an npm package.
Crete a
index.js
file at a root directoryExport your component in the
index.js
export { default as Test } from './dist/your_component_name';
- Update the
package.json
file
"babel": {
"presets": [
"@babel/preset-react"
]
},
Use the specific version of babel/cli
"devDependencies": {
"@babel/cli": "^7.22.9"
}
for Windows
"publish:npm": "rmdir /s /q dist && mkdir dist && babel src/components -d dist --copy-files",
for Mac/ Linux
"publish:npm": "rm -rf dist && mkdir dist && babel src/components -d dist --copy-files",
After complete development
npm run publish:npm
Make sure you are having a npm account
npm login
Enter your all details while logging
npm publish
Make sure your project name is unique, else update the name from package.json