vue cli - Uncaught SyntaxError: Unexpected token <

前端 未结 14 2288
说谎
说谎 2020-12-31 03:39

I create my project with vue-cli 3.0. Initially it runs ok. But after I -c then npm run serve again, it keep throwing erro

14条回答
  •  星月不相逢
    2020-12-31 04:06

    // 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/'
        : '/'
    };
    

提交回复
热议问题