简体   繁体   中英

Use of Node JS for Frontend

I have heard about Node.js being used in the frontend side of the application as opposed to the backend side, but I cannot find any use cases for which it can be used. Can somebody explain the use cases for which Node.js is used in the frontend.

Also for a fairly complex system such as a CMS(Content Management System) for an e-commerce site, would Node.js be the right choice?

Thanks in advance

Node.js is a javascript runtime that uses the Chrome V8 javascript engine. The front-end already uses a javascript engine on the browser (V8 for Chrome, SpiderMonkey for Firefox, Chakra for Edge), so whether Javascript is running in the browser on in Node.js, you can expect very similar environments.

However, you might be interested in using Node.js modules on the front-end. The modules are packaged using a tool called npm . You can use module loaders or bundlers like Browserify , webpack , or Rollup.js to accomplish this.

You'd usually use Node.js and its ecosystem as part of your toolchain when developing frontend applications, but the deployed application will still be regular JavaScript that runs in the user's browser. You can use Node's package manager npm instead of Bower for managing your frontend dependencies, for instance.

And there's Browserify which will let you use npm packages that were designed for Node in your frontend JavaScript application (that runs inside the user's browser).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM