1

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.

Sean Kearon
  • 10,987
  • 13
  • 77
  • 93
  • Well, does Node 8.3 support ES6 imports? The error message doesn't seem to have anything to do with VSC. – Bergi Aug 12 '17 at 12:10
  • Looking at [this](https://medium.com/the-node-js-collection/an-update-on-es6-modules-in-node-js-42c958b890c) article, it seems they are not yet supported. I guess that's the problem then, thanks! – Sean Kearon Aug 12 '17 at 12:15

0 Answers0