vue-cli-plugin-cordova icon indicating copy to clipboard operation
vue-cli-plugin-cordova copied to clipboard

Uncaught SyntaxError: Unexpected token <

Open ferdiaddawy opened this issue 6 years ago • 7 comments

I found this problem when running npm run cordova-serve command

image

ferdiaddawy avatar Jul 10 '18 09:07 ferdiaddawy

Edit: Apparently it's possible for Windows Powershell to lose elevated admin privileges. So, even though I ran it as admin, I was no longer admin when running the vue add cordova command. Now that I've discovered this and re-ran the command as admin, things are again working as expected. So perhaps this is a true duplicate.


Possible duplicate of https://github.com/dekimasoon/vue-cli-plugin-cordova/issues/14 however I'm now experiencing this too, and the solution to the previous issue is no longer working.

This was originally solved by simply running vue add cordova as admin (Windows). After that I had no issues, until a few days ago. I'm now working from a different computer with fresh installs of node (and everything else).

I'm now running all commands as admin and still getting this error.

@dekimasoon after running vue add cordova and cordova prepare, what should we find in the public directory?

chasebank avatar Jul 11 '18 05:07 chasebank

@chasebank I really appreciate your help. Thank you very much 🙏 The public directory should be like below. https://github.com/dekimasoon/vue-cordova-file-plugin-sample/tree/master/public

@ferdiaddawy Could you check if there are symlinks named cordova and config.xml in the public directory? If there aren't, please try vue add cordova as admin.

dekimasoon avatar Jul 11 '18 09:07 dekimasoon

I've checked the public folder available cordova and config.xml files

image

but after i run npm run cordova-serve command, there is a problem like the picture below

image

note: run with administrator mode

ferdiaddawy avatar Jul 12 '18 01:07 ferdiaddawy

@ferdiaddawy Sorry for my late repsponsing. I have no clue about your problem...

Cloud you please provide the reproduce repo?

dekimasoon avatar Jul 26 '18 05:07 dekimasoon

The problem is that the symlinks are created when vue add cordova is ran, but when you upload that to version control, they no longer work. You can run vue add cordova after deleting the unusable symlinks so they are recreated, but then there are things that get re-added in main.ts, App.vue, and .gitignore. You can of course discard the changes in version control, but that just seems dirty. So I ended up ignoring public/cordova and public/config.xml, and re-creating symlinks for every fresh clone with: mklink /J public\cordova platforms mklink /H public\config.xml platforms\browser\config.xml

The error you were getting @ferdiaddawy was because although you have the symlinks, you do not have the config.xml in platforms/browser. You need to run cordova prepare for that to be generated, and I've found that after a fresh clone, you must run cordova prepare twice for the browser folder to get generated. Don't really know what's going on there.

So, 2 things:

  1. After vue add cordova has ben aready ran in a project, find a way to redo the symlinks only.
  2. Discover why only ios and android platforms are added the first time cordova prepare runs and needs a 2nd run to install the browser platform

cuzox avatar Aug 04 '18 15:08 cuzox

I was trying to explore the same concerns in #20

I cloned an existing project to one computer, and had a bunch of issues that I eventually worked through with some trial and error... but wasn't sure how stable it was. I had a lot of concern about the symlinks.

I just tried cloning to a third computer and this time things went much more smoothly.

I've actually left the default .gitignore as-is

And then for the cloning:

git clone ....
cd ....
npm install
npm run cordova-build
cordova prepare

Obviously I skipped vue add cordova so we don't get all the duplicate stuff. And I guess that's really the only difference.

After the initial npm install any cordova commands return an error that this does not look like a cordova project.

Running npm run cordova-build fixes that, by building out the www directory. Now cordova recognizes the project, and simply running cordova prepare adds all the platforms and plugins referenced in the config.

It also looks like the browser platform was added with the single prepare command.

It's possible part of this may be due to whatever changes I made when I first encountered issues. I haven't tried this in a fresh project yet, but so far so good. No errors.

chasebank avatar Aug 05 '18 21:08 chasebank

Hi, I'm found I'm getting this error randomly after a while working on the project. It seems that running vue add cordova again solves it. I don't see any symlinks in the public folder, even when the error isn't showing.

Does the vue add cordova command need to be run on every cloning of the project to a new machine?

syonip avatar Jan 03 '19 07:01 syonip