2

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.

4
  • 2
    Because 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#CDN Commented Nov 10, 2017 at 10:05
  • npm is a package manager. Vue.js is a package hosted on npm. Commented Nov 10, 2017 at 10:06
  • 2
    Relation is the same as between Laravel and Composer. Commented 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. Commented Nov 10, 2017 at 20:52

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

a lovely answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.