I create my project with vue-cli 3.0
. Initially it runs ok. But after I
then npm run serve
again, it keep throwing erro
Try by adding <base href="/" />
into the <head>
of your index.html. Hope it will work.
I have the same problem. in index.html file , I just write this script tag,like this :
<script src="./static/js/qrcode.min.js"></script>
if I change src attr like this:
<script src="/static/js/qrcode.min.js"></script>
ok, no error 'Unexpected token <' dispaly.
here is a another problem happened,it is upsetting to me .
online build product tests that dispaly I can't access this site and get resource. OMG ! ok, I change this src again like this:
<script src="./static/js/qrcode.min.js"></script>
and then make some changes in vue.config.js like this:
baseUrl:'./'
assetsDir:'./'
so,online everything is ok ,but in my local project run it will get this error.
finally,I find this :
online url address: http://xxxxx.cn/test0001/#/
local url address: http://192.168.5.108:9000/test0001/#/
(ps:test0001 params can't remove,my project need it)
if I remove this params 'test0001', this error isn't display in my local project test .
I guess build and development environment's difference cause this error,and my params test0001 in url address.
finally,I just use a param to diff this product and development to solve it.
if someone meet this problem like me , please share your solution.
I had the same problem. For me I solve it by adding the 'asset'
<script src="{{ asset('js/app.js') }}" defer></script>
Uninstalling both CLI's and reinstalling V3 + A 'hard' refresh in Chrome did the trick. Maybe a hard refresh alone was enough (CTRL + F5)
I had the same problem, I tried the removing node modules and npm install again but that didn't work.
What did work was removing all the site data. You can do that (in Chrome) by opening the development tab (Ctrl+Shift+i), go to the 'application' tab, click "Clear storage" on the side panel and click on the "Clear site data" button.
My guess is that I still had some old service-worker that intercepted the request and served the html file instead of the app.js. So if you have used PWA's before at the url "http://localhost:8080" this might solve the problem.
// vue.config.js
module.exports = {
publicPath: '/',
};
You actually want to add the publicPath to your vue.config.js file
https://stackoverflow.com/a/56320964/1321009 does work if you application is deployed at http://example.com
If you deployed it at http://example.com/something
Then you would need to go in and change it when deploying, annoying to say the least.
with vue.config.js file just set it like this
// vue.config.js
module.exports = {
publicPath: process.env.NODE_ENV === 'production'
? '/something/'
: '/'
};