when i want to work with vue.js in my laravel project , NPM should be installed. But what is the relation between npm and vue.js.
-
2Because Vue and its tools are hosted in npm registry. Anyway, you can use it without npm by directly declaring the link to the cdn vuejs.org/v2/guide/installation.html#CDNHéctor Valls– Héctor Valls2017-11-10 10:05:44 +00:00Commented Nov 10, 2017 at 10:05
-
npm is a package manager. Vue.js is a package hosted on npm.Martin Bean– Martin Bean2017-11-10 10:06:34 +00:00Commented Nov 10, 2017 at 10:06
-
2Relation is the same as between Laravel and Composer.user6748331– user67483312017-11-10 10:08:43 +00:00Commented Nov 10, 2017 at 10:08
-
It does not have to be installed to work with Vue.js. It has to be installed to work with Laravel mix and the default framework boilerplate which happens to include vue.js . You can still include Vue.js via a CDN if you want.apokryfos– apokryfos2017-11-10 20:52:34 +00:00Commented Nov 10, 2017 at 20:52
1 Answer
Yes, npm is a package manager, Vue.js has a package on npm and you can use Vue.js by including it directly (See the Vue.js installation guide). Yes, npm is also similar to composer where you can easily add and update packages.
However, by using npm you also have the ability to create single file components - with the style, template and script all located in one file. Then you can use CSS, LESS, SASS, Jade, ES6, etc in one place, and they'll be precompiled into vanilla CSS and JavaScript using, for example, WebPack. (See Vue.js single file components)
npm does not have to be installed for production - you'll only need the compiled vanilla CSS and JavaScript files that it outputs, but is very useful in development.