Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert NPM project to browser-compatible JavaScript file?

is it possible to convert a fairly small NPM package to a javascript file that I can reference in HTML with a <script> tag?

The NPM package that I am trying to do this with is not complex at all and is basically just an API wrapper that I'd like to use, but I don't want to use Node.

like image 619
Doctrx Avatar asked Aug 12 '26 17:08

Doctrx


2 Answers

use Browserify to convert NPM to a single js file and then refer it in your HTML file

like image 51
Emad Hejazian Avatar answered Aug 14 '26 07:08

Emad Hejazian


NPM is just a build tool, it helps you organise dependencies and much other.

You can manually make the particular *.js files you want from node_modules available for your html file and use them from there.

like image 26
Horatiu Jeflea Avatar answered Aug 14 '26 08:08

Horatiu Jeflea