Haixing-Hu / vue-datetime-picker

A Vue.js component implementing the datetime picker control using the Eonasdan's bootstrap datetime picker plugin.
http://haixing-hu.github.io/vue-datetime-picker/
MIT License
341 stars 77 forks source link

TypeError: Path must be a string. Received [ 'src/vue-datetime-picker.js' ] #5

Closed mhnrcjgs closed 8 years ago

mhnrcjgs commented 8 years ago

i tried to import it but i got this error. I'm still new with browserify and vue so this might me a minor issue. i need help. tnx.

var vm = new Vue({ el: "#app", components: { "vue-datetime-picker": require('vue-datetime-picker') },

this is the error when i run gulp path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path)); ^

TypeError: Path must be a string. Received [ 'src/vue-datetime-picker.js' ] at assertPath (path.js:7:11) at Object.resolve (path.js:184:7) at D:\path\node_modules\resolve\lib\async.js:151:37 at FSReqWrap.readFileAfterClose as oncomplete

vlatkoIT commented 8 years ago

I've received the same error, any thought or solutions how these can be solved ??

74sharlock commented 8 years ago

@dandruff123 find package.json, and change the "main" field to string type. There are other problems with this component, Source code has been inconsistent with current version of the datetimepicker plugin.https://github.com/smalot/bootstrap-datetimepicker

74sharlock commented 8 years ago

@dandruff123 ok, i wrote a very simple dateTimePicker component, like this:

let options = {
  useCurrent: false,
  showClear: true,
  showClose: false,
  minView: 2,
  fontAwesome: true,
  format: 'yyyy/m/d',
  autoclose: true,
  language: 'zh-CN'
};

export default Vue.component('datePicker', {
  replace: true,
  inherit: false,
  template: `<div class='input-group date'>
                <input class='form-control' v-model='model' type='text' readonly>
                <span class='input-group-addon'>
                  <i class='fa fa-fw fa-calendar'></i>
                </span>
             </div>`,
  props: ['model'],
  ready: function() {
    $(this.$el).datetimepicker(options);
  }
});

this is html:

<date-picker :model.sync="oneParentModel"></date-picker>

use Vue#1.0.21 && don't forget the datetimepicker plugin!

Chalkin commented 8 years ago

same problem when requiring the component in:

installing via "npm install vue-datetime-picker --save"

require('vue-datetime-picker');

path.js:8 throw new TypeError('Path must be a string. Received ' + ^

TypeError: Path must be a string. Received [ 'src/vue-datetime-picker.js' ] at assertPath (path.js:8:11) at Object.posix.resolve (path.js:426:5) at /Users/patrick/Sites/_webseiten/freelance-portal/spark/node_modules/resolve/lib/async.js:151:37 at FSReqWrap.readFileAfterClose as oncomplete

apstyx commented 8 years ago

It is not pretty but it works for me

components: { "vue-datetime-picker": require("vue-datetime-picker/src/vue-datetime-picker.js"), },

Haixing-Hu commented 8 years ago

It has been fixed in the last release.