0

here is my code

// var htmlplugin = require('html-webpack-plugin'); // works!

import htmlplugin from 'html-webpack-plugin'; //not working

when I npm run dev shows erros like:

import htmlplugin from 'html-webpack-plugin'
^^^^^^
SyntaxError: Unexpected token import
Trott
  • 66,479
  • 23
  • 173
  • 212
kuzicala
  • 25
  • 8
  • Possible duplicate of [NodeJS plans to support import/export es6 (es2015) modules](https://stackoverflow.com/questions/37132031/nodejs-plans-to-support-import-export-es6-es2015-modules) – YLJ Jun 14 '17 at 08:08

1 Answers1

1

import is not yet supported in Node.js. Node.js uses Google's V8 for its JavaScript engine. The version of V8 currently shipping with Node.js does not support import. (I don't think even the most recent V8 supports it without a command line flag.)

Once import is supported, it still might not support CommonJS modules like those typically installed by npm (although perhaps it will because there is some ambitious work on interoperability--time will tell).

Trott
  • 66,479
  • 23
  • 173
  • 212