vuetiful icon indicating copy to clipboard operation
vuetiful copied to clipboard

dateFns is not defined

Open Voidmine opened this issue 7 years ago • 8 comments

When I try to use this, I get an error that says:

Uncaught ReferenceError: dateFns is not defined at Object.defineProperty.value

Voidmine avatar Aug 06 '17 13:08 Voidmine

If you're using webpack and have the proper loaders configured you can...

import Vuetiful from 'vuetiful/src/main.js'
Vue.use(Vuetiful)

TomKaltz avatar Aug 11 '17 04:08 TomKaltz

Please see https://github.com/andrewcourtice/vuetiful/pull/34/commits/7ff9035bb78b229fc0101362e1a85488ccb5dd6b#diff-11e9f7f953edc64ba14b0cc350ae7b9d for a possible fix.

litti avatar Aug 30 '17 20:08 litti

@TomKaltz Which loaders are needed? I have the default from Vue CLI, and running npm run build causes an issue

RIanDeLaCruz avatar Sep 03 '17 00:09 RIanDeLaCruz

@RIanDeLaCruz What exactely is the issue?

litti avatar Sep 03 '17 15:09 litti

@litti a named export was getting errors in the build

Solved it by manually adding Vuetiful to my babel-loader.

Is there another way?

RIanDeLaCruz avatar Sep 03 '17 22:09 RIanDeLaCruz

I did the following:

  1. yarn add date-fns
  2. Added window.dateFns = require('date-fns'); to my main .js file

I am using Laravel and Laravel Mix though, so YMMV.

vmitchell85 avatar Sep 14 '17 15:09 vmitchell85

I have the same problem.

My package.json:

 "dependencies": {
    "core-js": "^2.4.1",
    "date-fns": "^1.28.2",
    "vue": "^2.5.2",
    "vue-router": "^3.0.1",
    "vuetiful": "github:andrewcourtice/vuetiful"
  },

my vue file:

<script>
import Vuetiful from 'vuetiful/dist/components/components.bundle';
Vue.use(Vuetiful);

and some js and markup from datatable example.

I have error in js console: ReferenceError: dateFns is not defined

I think it is better remove dateFns dependency from library and make it optional.

razbakov avatar Jan 22 '18 15:01 razbakov

If you want to use date-fns via Script tag, add this to your HTML file.

from author's original code

greentec avatar Dec 14 '18 02:12 greentec