Skip to content

--harmony_modules isn't working? #2760

Closed

Description

@tusharmath

Following the documentation given here https://nodejs.org/en/docs/es6/

Sample Code

import {partial} from 'lodash'
console.log(partial)

command

node --harmony_modules  Javascript.js
/Users/tushar.mathur/Documents/Projects/temp/Javascript.js:1
(function (exports, require, module, __filename, __dirname) { import {partial} from 'lodash'
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:413:25)
    at Object.Module._extensions..js (module.js:452:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:475:10)
    at startup (node.js:117:18)
    at node.js:951:3
➜  temp

OS: Mac OS 10.10.4
Node: 4.0.0

Activity

  1. fl0w commented on Sep 9, 2015

    @fl0w

    Same results here, also on OS X (also with strict mode).
    However, I'm not sure it is expected to work - I'm still transforming with BabelJS.

  2. tusharmath commented on Sep 9, 2015

    @tusharmath
    ContributorAuthor

    I guess I tweeted too soon :'(

    Yay! ES6 modules finally :) https://t.co/g9oKPYXEEw

    — Tushar Mathur (@tusharmath) September 8, 2015
    <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
  3. fl0w commented on Sep 9, 2015

    @fl0w

    modules are still in 'in progress' in v8 - so I'd withdraw that tweet anyway!

    $ node --v8-options | grep 'in progress' 
    
  4. tusharmath commented on Sep 9, 2015

    @tusharmath
    ContributorAuthor

    Well, I wanted to experiment with them without using a transpiler which I finally could (Or can't).

  5. ilkkao commented on Sep 9, 2015

    @ilkkao

    See this comment: https://code.google.com/p/v8/issues/detail?id=1569#c29

    V8 developers are currently waiting WHATWG loader spec to mature before completing the ES2015 module support.

  6. bnoordhuis commented on Sep 9, 2015

    @bnoordhuis
    Member

    Closing. As others point out, ES6 modules are not implemented in V8 yet. As a rule of thumb, if a feature is behind a flag, you can expect it to be half-baked or downright broken.

  7. added
    v8 engineIssues and PRs related to the V8 dependency.
    on Sep 9, 2015
  8. nguyenchilong commented on Nov 30, 2015

    @nguyenchilong

    I have problem with '--harmony' in command, and use AppJS module node --harmony ./app/app.js and after run then have error 'AppJS requires Node is run with the --harmony command line flag' pls help me for this error. I use xubuntu OS node v4.2.2.
    have add '--harmony' or no then always show error message 'throw new Error ('AppJS requires Node is run with the --harmony command line flag'); ^
    Error: AppJS requires Node is run with the --harmony command line flag
    at Object. (/var/www/tutorial/app/node_modules/appjs/lib/index.js:2:9)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Module.require (module.js:366:17)
    at require (module.js:385:17)
    at Object. (/var/www/tutorial/app/app.js:3:11)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)'

  9. Globik commented on May 15, 2016

    @Globik

    And by now what? Is import implemented in node.js 6.0?

  10. fl0w commented on May 15, 2016

    @fl0w

    AFAIK, V8 still doesn't support import/export, and thus neither does node.js v6.

  11. d3x0r commented on May 15, 2016

    @d3x0r
    Contributor

    https://bugs.chromium.org/p/v8/issues/detail?id=1569

    Mar 16, 2016

    Remove --harmony-modules flag and let embedder decide when modules are used

    Modules already have a separate entrypoint into the engine (at the moment,
    this is v8::ScriptCompiler::CompileModule, though that will change to
    something like ParseModule). This meant that requiring a commandline flag
    simply added an extra complexity burden on embedders. By removing the v8
    flag, this lets embedders use their own flagging mechanism (such as d8's
    "--module", or Blink's RuntimeEnabledFeatures) to control whether
    modules are to be used.

    Also remove old modules tests that were being skipped (since they test
    very old, pre-ES2015 modules syntax).

  12. quantuminformation commented on May 21, 2016

    @quantuminformation

    sad

  13. skrat commented on Jun 6, 2016

    @skrat

    Yeah, keep the ticket closed. Modules in JS will never be truly standardized, and if they will, the standard will be obsolete or deprecated the next day, by a new solution, "new standard". Sad.

  14. cweilguny commented on Aug 29, 2016

    @cweilguny

    As node 6.5.0 still throws up on import ..., I guess it's still not in V8? Any news on that?
    http://node.green/ is a great resource, but is there module support shown in any way?

  15. simonbengtsson commented on Jan 12, 2017

    @simonbengtsson

    V8 now has support for modules! And implementation has started in chromium 🎉🏆🎊 https://bugs.chromium.org/p/chromium/issues/detail?id=594639#c9

  16. avesus commented on Dec 23, 2017

    @avesus

    Node 9.3.0 still not supported.

  17. devsnek commented on Dec 23, 2017

    @devsnek
    Member

    @avesus i believe modules are slated for node 10 (i don't know if they will be backported). however you can use them in nightly builds with --experimental-modules

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    v8 engineIssues and PRs related to the V8 dependency.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions