Browserify: Use require() In Client Side JavaScript

preview_player
Показать описание
Browserify bundles your JS code with the source of all the modules you included and makes a new JS file.

No need to use multiple script tags for different JS files, just bundle them and add once.

Other videos you might like:

My Socials:
Рекомендации по теме
Комментарии
Автор

sorry but i get this error when i run it: The term 'browserify' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or
if a path was included, verify that the path is correct and try again.
At line:1 char:1 .. how to fix it? u want futher details? like my code?

onnvvv
Автор

I have this error
> browserify main.js -o bundle.js
Error: Can't walk dependency graph: Cannot find module '/home/..../.../.../main.js' from '/home/.../.../.../_fake.js'
required by /home/.../.../.../_fake.js

srthrtfghtgfrydh
Автор

Thank you very much. This removed the block I had about how to use server-side code in the browser.
I complemented browserify with beefy for auto reload and works incredibly. Even more, I got to understand the concept of "shipping to production". Given that beefy works locally but not when commiting the project to Github, for example. Keep doing this man, great resources!!

quesoapasionante
Автор

Hey man, I had a doubt just today while testing Beefy for auto reload. Would appreciate your help:
Beefy seems to work fine when using it with a main.js connected to an index.html. But then I start working on an inside folder and call a file named v1.js. All I see when getting to the (//127.0.0.1:9966) port is a blank document, only the JS is visible via the browser´s console but the v1.html file I have set up to interact with that v1.js is not displaying. Have any idea why this happens?

quesoapasionante
Автор

Bro...I like ur content but..please do something for audio... Audio is very low.

mridulsharma
Автор

Do i need to cd into the app folder when installing and when I bundle the scipt? If Im not doing that it cant find "main.js" and if I do I still get require is not defined..

SonalK
Автор

This is exactly what i needed. Thanks bro!!

arthurimona
Автор

After installing it with npm, I still can't use require of Node in vanila javascript. It shows error in browser: Uncaught ReferenceError: require is not defined.
How to fix it?

danielhat
Автор

SCRIPT5007: Unable to set property 'innerHTML' of undefined or null reference

i keep on getting this error

misskye
Автор

when we make some change to main.js, do we need to run the command everytime in terminal ? or can we add a config ?

Tharunu
Автор

works for many modules but with better-sqlite3 it didnt work !

revenge
join shbcf.ru