Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

how to use npm packages in html

npm install the packages in the node_modules folder, the front end
cannot use it directly, you need ES6 syntax and import them by
using the following code:

import html2cavas from "html2cavas"

then you need to use Babel to transpile your ES6 code to normal JS code
Here is the explanation:
https://hackernoon.com/use-es6-javascript-syntax-require-import-etc-in-your-front-end-project-5eefcef745c2

After that you can use the <script> tag to import the transpiled code
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #npm #packages #html
ADD COMMENT
Topic
Name
2+2 =