vue-cli: SyntaxError: Unexpected token import on fresh project
Version
3.0.0-beta.15
Reproduction link
Steps to reproduce
- vue create vue-project
- cd vue-project
- jest tests/unit/HelloWorld.spec.js --no-cache
What is expected?
The test case is executed with no errors
What is actually happening?
Test suite failed to run
Adding the following block to babel.config.js fixes this particular error
env: {
test: {
presets: ['@babel/env'],
},
},
but it raises another error: http://take.ms/jlxuP
And this happens because import doesn’t work for some reason.
When I change
import HelloWorld from '@/components/HelloWorld.vue';
to
const HelloWorld = require('../../src/components/HelloWorld.vue').default;
it works fine: http://take.ms/ILHes
P.S. Unaliased import doesn’t work as well:
import HelloWorld from '../../src/components/HelloWorld.vue';
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 18 (4 by maintainers)
Yes, it’s under
~/.npm