npm-browser

install npm packages in browser

Usage no npm install needed!

<script type="module">
  import npmBrowser from 'https://cdn.skypack.dev/npm-browser';
</script>

README

npm-browser

Install like a node package manager in the browser

Think of this as requirejs but in a lighter version

  • Lightweight (1kb)
  • No Dependencies

Installation

Unpkg

<script src="https://unpkg.com/npm-browser"></script>

Usage

<script src="https://unpkg.com/npm-browser"></script>
<script>
    npm("sweetalert jQuery",(swal,$)=>{
        swal("Hello world")
        $("body").on("click",()=>{
            alert("hello world")
        })
    })
    
    // Specify the version
    npm("sweetalert@1.0.0",(swal)=>{
        swal("...")
    })
</script>

Packages name must be separated by spaces just like installing a package on npm

TIP: spaces can be many as you want

The base url of this package was https://unpkg.com/** if you dont want the default baseUrl you can change it via:

npm.baseUrl = "https://cdn.jsdelivr.net/npm/"