At the present time, wherever you look, any useful library connects to the npm install project ... But what if the server is not a node, but, for example, Golang? With some large libraries, you can do it by simply connecting it to the script tag on the page, but many people can’t find just the js file. For example, there is a need to connect to the project vue-native-websocket . How to deal with this? Maybe my question is stupid and I do not understand some basic things, but how do the front-tenders, who develop without nodejs, deal with this?
2 answers
You do not need to use NodeJS
as a server, it only allows you to run JS
outside of the browser. Usually it is necessary for assembly, for example using Webpack
, Gulp
, Grunt
.
NPM
- in turn, acts as a package manager, which downloads library files, possibly with source code, which is then built by the same webpack
.
All this is necessary in order to connect and collect only the functions you need, and not to drag heavy libraries "for the sake of one button."
Look for courses on the Internet, see what is ES5, ES6, etc., use import
or require
, Webpack'ом
project with a Webpack'ом
all this is much more convenient than writing script
tags and downloading libraries manually.
- But as far as I understand, the webpack is also a Node theme - Anton Kazakov
- Well, this is just the same
JS
library, which is launched usingNodeJS
, but as Stranger in the Q wrote, it runs only once - Komdosh
The server has nothing to do with it. The client code is a separate footwoman, but it is built using node.js
, but once on the developer’s machine (or the build system, this is not important here), and the server-server. In general, for example, I have a backend on java
, and now I don’t use libraries? =)
Then, it is absolutely not necessary to collect everything in one bundle, you can connect scripts as usual with script
tags, most libraries that respect themselves and their users support all connection methods.