Reputation: 1355
I have been attempting to publish an npm package for react but keep running into issues. More specifically, after I publish my package and go to test it, the installed package has errors related to the jsx.
I built the published package with create-react-app
and then added an additional package.json
in the specific directory I wanted to publish.
I assume my issues are because create-react-app
expects you to use the root
package.json
and not a separate one within the project. So this leads me to believe there are Webpack or Babel configurations I need to handle. I am having trouble finding this information.
The directory I am trying to publish only has 3 files other than my package.json
which looks like this
{
"name": "...",
"version": "1.0.0",
"description": "...",
"main": "index.js",
"peerDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"keywords": []
}
this has so far been unsuccessful. I have also attempted the following
{
"name": "...",
"version": "1.0.0",
"description": "...",
"main": "index.js",
"peerDependencies": {
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
"babel": {
"presets": [
"@babel/preset-react"
]
}
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"license": "ISC",
"keywords": []
}
Im not sure what I am missing
Upvotes: 1
Views: 161
Reputation: 249
You can use the create-react-library for creating packages for React and publishing those to NPM.
Upvotes: 1