简体   繁体   中英

Node.js is generally code running on the server; what role does it play in front-end project development?

Generally, when writing vue.js front-end projects, node.js is used. For example, npm installs some node.js three-party packages to node_modules/.

  1. Excuse me, node.js is generally the code running on the server side; what role does it play in front-end project development? Is it just npm run dev to run the webserver like this?

  2. Or can Node.js also write some front-end code? But Node.js is a program running on the server, how can you write front-end code?

First of all, Node.js is a runtime environment that can run JavaScript, which is similar to the JavaScript runtime environment embedded in the browser. In fact, Node.js is ported from Chorme's built-in V8 JavaScript runtime environment;

Then, Node.js can be used as a server, running the server. It can also be used as a scripting tool. Now the front-end package management and packaging tools are all Node.js scripts;

To sum up, the difference between front-end code and back-end code is: where does it run? The client (front-end) runs client-side code, and the server-side runs server (back-end) code.

Node.js is a runtime environment. There is no such thing as writing front-end or back-end code. It can be said that it runs front-end packaging scripts, and runs JavaScript server-side code. The JavaScript server can serve the front-end, such as server-side rendering.

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