0
votes

I am trying to import a node module into my Vue project and am getting the following error:

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

I understand that this is probably due to the node module not being transformed by babelify but I am not sure how to fix it.

My code can be found here:

https://github.com/timothyylim/vue-date-picker-example

Running

npm install 
npm run dev 

should show the error. I simply started with the vue-cli browserify template and tried to pull in a date picker component.

Any help would be greatly appreciated!

1
I guess I'm too late for this one, after posting the edit to my answer realise you were the one that opened the ticket on the data-picker component. - a--m

1 Answers

0
votes

Follow the readme of the project you linked and use vue-cli: ~

npm install -g vue-cli
vue init browserify my-project
cd my-project
npm install
npm run dev

Follow up the command-line instructions, I had to install also @vue/cli-init as suggested. By the time being this worked, I can see the vue-cli compiles the same example you pointed out.

EDIT:

Looks like this was a issue with the component weifeiyue/vue-datepicker-local, it was recently fixed here:

https://github.com/weifeiyue/vue-datepicker-local/commit/a6e3078936a37acc1d6344b7b4d8c14b42be0844

The solution should be as simple as update the component.