'Building Vue app after upgrading to version 5 starts throw "Uncaught SyntaxError: Unexpected token ':'"
After upgrading @vue/cli-service to version ^5.0.4. the build command is not functioning normally as before. after building vue js for production, this was showing Uncaught SyntaxError: Unexpected token ':' in the console. After checking the code, The error was coming from
const Ee = () => `http://localhost:85/${Se()}`, Se = () => Ce() && we() ? 'api' : 'v1/api',
Ce = () => 'DEVELOPMENT' === {
NODE_ENV: 'production',
VUE_APP_API_URL: 'http://localhost:85/',
VUE_APP_URL: 'http://localhost:8080/',
BASE_URL: '/'
}?.VUE_APP_ENVIRONMENT, we = () => {
NODE_ENV:'production', VUE_APP_API_URL
:
'http://localhost:85/', VUE_APP_URL
:
'http://localhost:8080/', BASE_URL
:
'/'
}
I appreciate any help.
Solution 1:[1]
After Better Indentation and pasting code in visual studio code. I found this
Notice the red squiggly line on lines no. 17, 18, and 19. This is happening because javascript is expecting a function body and you are returning an object.
const we = () => ({ VUE_APP_API_URL: 'http://localhost:85/' })
Note: the round bracket before the curly bracket.
() => ({ ... }) instead of () => { ... }
Hope this helps
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | ThatsME |

