create-npm-package | Creates an npm package boilerplate | Runtime Evironment library
kandi X-RAY | create-npm-package Summary
kandi X-RAY | create-npm-package Summary
Creates an npm package boilerplate that you don't have to write again :package:
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of create-npm-package
create-npm-package Key Features
create-npm-package Examples and Code Snippets
Community Discussions
Trending Discussions on create-npm-package
QUESTION
I was following this tutorial and it's been a week I tried to resolve the issue:
...ANSWER
Answered 2019-Mar-28 at 17:45TLDR: Detailed step by step guide
A couple things have changed since the writing of the tutorial namely the following are the breaking changes, unless listed otherwise the other steps in the tutorial are the same:
You will need to download and use the
babel-cli
in order to get your custom "lib" script command to work:npm install --save-dev @babel/cli
You will also need to download and use the
@babel/plugin-transform-react-jsx
plugin within your custom "lib" script command to compile and transform your React code since Babel 6 and up no longer have any native transforms for React. This is necessary for when you want to share your custom component with only native JavaScript on npmjs for others.npm install --save-dev @babel/plugin-transform-react-jsx
Update your "lib" script command to use the babel's JSX transforming plugin listed in step 2:
"scripts": { "start": "node scripts/start.js", "build": "node scripts/build.js", "lib": "babel --plugins @babel/transform-react-jsx src/node_modules --out-dir lib --copy-files", "test": "node scripts/test.js" },
Note: You also don't need the .babelrc
file listed in the tutorial as we will edit the webpack.config.js
file to properly transpile JSX
later on.
Steps 1 - 3 will allow you to publish and share your component with others, but you will still have to make adjustments for your local development and I will describe those steps below:
For your custom component's
package.json
remove the.js
extension for the"main"
entry point as this will cause the following issue. For example, here is my custom component'spackage.json
:{ "private": true, "name": "YourComponent", "main": "./YourComponent" }
Now if you try to compile and run your application locally, using your custom component, it will throw an error complaining about your custom component's JSX
syntax:
SyntaxError: YourComponent.js: Unexpected token (6:6)
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install create-npm-package
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page