Sign in to follow this  
State Valentin

Requiring a npm package inside Client-side ?

Recommended Posts

Ok so my index.js from server-side looks like this:


// Loading official packages of the server

const glob = require('glob');  
const config = require('./config.js');

glob ('./packages/semp/Assets/**/*.js', function(err,files) {  
  for (file of files) {
    if(config.env == 'dev') { 


I want to do the same to the client-side packages. But how can i do that if i can't load an npm package with Vanilla JS ? Any fix to that ? 

Share this post

Link to post
Share on other sites

Wrong area to post this, but the client-side JS supports the require function to load in other files.

For using packages from NPM you just have to include them in your client_packages directory so they get sent to each client. I suggest something like Webpack to handle bundling for you.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.