Use the vue - cli create project running npm run dev error.
Error:
ERROR in ./src/main.js
error Parsing error: The keyword 'import' is reserved
/Users/leemuzi/code/workspace/aoyou-code/m.aoyou.com-FED/2016_develop/develop/wifi_pass(201603)/src/main.js:1:1
import Vue from 'vue'
Could you tell me how to solve I change,please!
Code without Babel translation?
@lee134134134 Is this happening on a freshly generated, unmodified project? My suspicion is you may have modified .eslintrc to a configuration that does not allow modules.
Hello @lee134134134,
@chrisvfritz is right about the eslint thing.
I just got the same issue, I chose to configure the eslint myself (no standard, no airbnb).
So I have this .eslintrc.js file after the vue init webpack my-project:
module.exports = {
root: true,
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
You need to add this to enable ES modules:
parserOptions: {
sourceType: 'module'
}
So your file is now:
module.exports = {
root: true,
parserOptions: {
sourceType: 'module'
},
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
'rules': {
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0
}
}
My npm run dev output is now:
siegfried@home ~/dev/vue-people (git)-[develop] % npm run dev :(
> [email protected] dev /home/siegfried/dev/vue-people
> node build/dev-server.js
Listening at http://localhost:8080
webpack built da12e0ee4af97cbde1cd in 715ms
Hash: da12e0ee4af97cbde1cd
Version: webpack 1.13.0
Time: 715ms
Asset Size Chunks Chunk Names
app.js 275 kB 0 [emitted] app
index.html 220 bytes [emitted]
Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 21.4 kB 0
webpack: bundle is now VALID.
All good !
@SiegfriedEhret Thanks for the confirmation and additional information! :tada:
@SiegfriedEhret I could hug you right now, was driving me crazy because it would build one time, fail the next time, and this fixed it.
Most helpful comment
Hello @lee134134134,
@chrisvfritz is right about the eslint thing.
I just got the same issue, I chose to configure the eslint myself (no
standard, noairbnb).So I have this
.eslintrc.jsfile after thevue init webpack my-project:You need to add this to enable ES modules:
So your file is now:
My
npm run devoutput is now:All good !