A, JavaScript,

Traditional JavaScript runs on a browser because the browser kernel is split into two parts

  • Rendering engine: Render HTML && CSS
  • JavaScript engine: Runs JavaScript. As the technology has evolved, Chrome uses a JavaScript engine called V8, which is very fast and high performance, and was developed by Ryan Dahl in May 2009.

What is Node.js

Node.js is a JavaScript environment based on Chrome V8 engine, which runs JavaScript on the server side. Node.js uses an event-driven, non-blocking I/O model, making it lightweight and efficient.

  1. Nodejs is a powerful JS runtime environment, similar to the JVM for Java. Therefore, js support is very good, and has spawned a series of APPLICATION development based on JS. The growth and expansion of applications derived from various JS led to the birth of NPM
  1. NPM is a package manager based on the Node JS environment. Why is there no NPM in pure JSP/PHP? Because there is no support for a powerful JS runtime environment like NodeJS. Nodejs spawned the JS boom, which in turn spawned NPM to package and manage these JS-BASED applications
  1. As the web elements of front-end development continue to enrich and complicate, the Emergence of Webpack to further plan the package deployment of JS applications. Front-end target page resources are packaged and compressed through Webpack.
  1. As you can see, vue.js is deployed in webpack mode. After using NPM run build, we will generate a target Dist file. This is the target static Web resource, placed under nginx and accessible through a web page.

In summary, vue.js is packaged via WebPack, which in turn is based on NPM, which requires a NodeJS environment. This is why vue.js also requires the nodeJS environment to be installed.

Copy the target Dist folder to an Nginx server that does not have NodeJS installed, and the access page responds properly to the logic. This has nothing to do with NodeJS, the server is not nodeJS, it is Nginx. If you use NodeJS to deploy the server, you need to install NodeJS on the target.

To put it simply: you can either develop nodeJS as a service or package your target front-end pages with nodeJs-based NPM && WebPack. Vue.js is packaged using Webpack, so nodeJS environment is required.

Refer to the article