I'm using VS Code 1.15 on Windows 10 and playing with ES6 in a .js
file.
I can import using require
with no problem:
var deepFreeze = require('deep-freeze'); // works
However, import
does not work.
import deepFreeze from 'deep-freeze';
The above gives the following error:
SyntaxError: Unexpected token import
at createScript (vm.js:74:10)
at Object.runInThisContext (vm.js:116:10)
at Module._compile (module.js:537:28)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
at Function.Module.runMain (module.js:609:10)
at startup (bootstrap_node.js:158:16)
at bootstrap_node.js:578:3
I've got Node 8.3 installed and am using the following js.config
:
{
"compilerOptions": {
"target": "ES6"
},
"exclude": [
"node_modules",
"**/node_modules/*"
]
}
What am I missing?
Update: The error above is from running the JS file using the Code Runner extension. But running it with Node also doesn't work.