alfhen / vue-cookie

A Vue.js plugin for manipulating cookies
MIT License
822 stars 74 forks source link

<script> tag doesn't work #18

Closed felipecaldas closed 6 years ago

felipecaldas commented 7 years ago

Hi there,

Just installed this module and in my client HTML I have :

I am getting a 404 from NodeJs: GET http://localhost:3000/node_modules/vue-cookie/build/vue-cookie.js GET /node_modules/vue-cookie/build/vue-cookie.js 404 8.950 ms - 2634

is it not possible to read straight from the node_module?

Thank you

felipecaldas commented 7 years ago

And, I did check the node_modules folder. vue-cookie is there :)

paladosss commented 7 years ago

I think this does not work because I have poorly defined the connections.

// Require dependencies var Vue = require('vue'); var VueCookie = require('vue-cookie');

Where should I do this?

felipecaldas commented 7 years ago

That would be in your server side, @paladosss I am trying to do that in the client side.

Dried09 commented 6 years ago

You may use something like webpack, if so - when you build your app or start dev server, open page with script tag in browser described file path does not exists, because build of your application has no folder node_modules, all dependencies will be bundled, but, probably, not dependencies imported via script tag.

To fix this problem you can use lib path from cdn, i.e.:

<script src="https://cdn.jsdelivr.net/npm/vue-cookies@1.5.6/vue-cookies.min.js"></script>

or create (or locate if it already exists) public folder in root of your project, place vue-cookie.min.js here and link it like:

<script src="./vue-cookies.min.js"></script>