ES Modules in NodeJS and the Browser

  Рет қаралды 7,363

Steve Griffith - Prof3ssorSt3v3

Steve Griffith - Prof3ssorSt3v3

Күн бұрын

Пікірлер
@ambrozykleks626
@ambrozykleks626 3 жыл бұрын
this channel is one of the best source of JS on the internet. I love the way prof is speaking english. Learning JS and beautiful english at the same time. Brilliant :)
@tahasoft1
@tahasoft1 3 жыл бұрын
In package.json just add "type": "module" then no need to rename the files to mjs
@RogerThat902
@RogerThat902 3 жыл бұрын
did not know that. That's a great tip. Thanks.
@satya4866
@satya4866 3 жыл бұрын
Awesome topic you selected here. Thank you very much.
@damo190
@damo190 3 жыл бұрын
Wao Steve, your are the best teacher. 🙏👏👏. Since many months I was searching for this topic on how to use import in nodejs. 🤩
@marie-elizeventer7080
@marie-elizeventer7080 2 жыл бұрын
Thanks
@marie-elizeventer7080
@marie-elizeventer7080 2 жыл бұрын
I was completely in the dark with module imports not working in the browser and in node, but this made it all so clear. Thanks Steve!
@nicopicco
@nicopicco 3 жыл бұрын
Thanks. That explains why we type certain things when importing stuff from React or React DOM or even material UI.
@metanevis
@metanevis 3 жыл бұрын
thanks a lot. it helps me . import/export or how files work together is question of many beginners like me
@mackenmd
@mackenmd 3 жыл бұрын
Great video, thank you very much! I really like the thoroughness and pacing of your videos and hope your channel grows in subscriber count as the secret gets out. I just attempted to get an electron app working with ES6 modules and failed. I used both the package.json settings method as well as the changing the extension to mjs method and nothing worked. It was super frustrating as I really want to share some code back-and-forth between websites and electron apps. It would be interesting to see if you could get a "hello world" electron app working with es6 modules. Thanks in advance if you decide to tinker with that and share your findings.
@firedforfighting
@firedforfighting 3 жыл бұрын
you could use which ever module type you like commonjs or esm for your app and just use webpack to bundle it into a UMD format and it will automatically choose the appropriate one..I use this recently on a small project
@mackenmd
@mackenmd 3 жыл бұрын
@@firedforfighting Thank you for taking the time to give me advice-I will try this.
@mykalimba
@mykalimba 3 жыл бұрын
I'd be interested to see a sensible scheme for how to organize the shared scripts for a project (basic node/express/mongodb). Maybe that's outside the scope of this particular video, but it seems like a logical next step? My project's back-end-only scripts exist in top level folders named "controllers", "models", "routes", etc. The project front-end is in a top-level "public" folder, and its scripts are in "public/js". I think if I want to share scripts between the back- and front-end, they would have to go somewhere in the "public" folder (otherwise it's impossible for the front-end to see them). Maybe in a "public/shared" folder, but that feels a bit messy?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
Folder structure will vary a lot depending on the project. There is no single project structure that will work for everything. The important thing is having a structure that you plan out, document, and then stick to. Not sure what scripts you would want to share between client and server. Code should either be for the server or the client. You don't want to send your back end controllers or routing files to the client. Any client side scripts that have to do with the DOM are not needed on the server.
@suryapratap3622
@suryapratap3622 6 ай бұрын
thanks you for explanation
@yinonelbaz5309
@yinonelbaz5309 3 жыл бұрын
Thank you so much I got smart
@satya4866
@satya4866 3 жыл бұрын
Can you make a video about commonjs and then explain the difference between the two types of modules, please and tha k you.
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 3 жыл бұрын
You can add tutorial requests in the comments here - kzbin.info/www/bejne/gnTIq5SuZ9qBacU and vote for requests you support.
@cgarafulic
@cgarafulic 2 жыл бұрын
Hello Steve, again a great tutorial as always. Something that happened in the browser is that after installing and importing node-fethc, the browser report an error "Uncaught TypeError: Failed to resolve module specifier "node-fetch". Relative references must start with either "/", "./", or "../".". Why is that happening?
@SteveGriffith-Prof3ssorSt3v3
@SteveGriffith-Prof3ssorSt3v3 2 жыл бұрын
node-fetch is a library meant to be used with Node (on the server-side) not in the browser. In the browser you can't load things directly from a node_modules folder. You have to give the full path.
@ballonura
@ballonura 3 жыл бұрын
Thx
@SirusStarTV
@SirusStarTV 3 жыл бұрын
Likes one oh one
Register and Login Full Lifecycle with NodeJS
27:11
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 11 М.
Scaling your Node.js app using the "cluster" module
13:44
Software Developer Diaries
Рет қаралды 50 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
Using Import Maps with ES Modules
8:07
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 4,6 М.
Closures, Currying and Partial Application
21:39
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 5 М.
Node.js Tutorial - 16 - ES Modules
9:46
Codevolution
Рет қаралды 49 М.
go is great i hate it
14:44
SST
Рет қаралды 25 М.
Revealing the Differences between HTML Dialogs and the Popover API
24:14
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 9 М.
Click a Button, Destroy My Site
11:40
Hyperplexed
Рет қаралды 104 М.
Deep Dive into Blobs, Files, and ArrayBuffers
17:42
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 38 М.
Error First Callback Patterns in JS
10:03
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 5 М.
JavaScript Classes in 2021
25:31
Steve Griffith - Prof3ssorSt3v3
Рет қаралды 8 М.
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН