Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--experimental-modules flag appears to be ignored #4385

Closed
Andrey-Bushman opened this issue Aug 8, 2019 · 5 comments
Closed

--experimental-modules flag appears to be ignored #4385

Andrey-Bushman opened this issue Aug 8, 2019 · 5 comments
Labels

Comments

@Andrey-Bushman
Copy link

I saw similar issue here, but it is old and closed. Therefore I create new issue.

Here is the simple example. It shows the problem. Look its readme.md file, please. How can I solve the problem?

Thank you.

@Andrey-Bushman
Copy link
Author

Andrey-Bushman commented Aug 9, 2019

I found issue #3751 and tried to use esm module instead of --experimental-modules option. It works fine. I will use it now. But it is workaround. It would be nice if the --experimental-modules option worked too (in the example I pushed to GitHub above).

Thank you.

@sidvishnoi
Copy link

sidvishnoi commented Aug 14, 2019

The --experimental-modules flag works with pm2, but it doesn't take "type": "module" from package.json into account.

Example code:

// foo.js
export const foo = "bar";

// index.js
import { foo } from './foo.js';
console.log(foo)

// package.json
{
  "type": "module"
}

Running with node directly:

$ node -v
v12.6.0
$ node --experimental-modules index.js
(node:11912) ExperimentalWarning: The ESM module loader is experimental.
bar

Running with pm2:

$ pm2 --version
3.5.1
$ pm2 start index.js --node-args="--experimental-modules"
$ pm2 logs index --raw --err

(node:9712) ExperimentalWarning: The ESM module loader is experimental.
E:\GitHub\pm2-test\index.js:1
import { foo } from './foo.js';
       ^

SyntaxError: Unexpected token {
    at Module._compile (internal/modules/cjs/loader.js:720:23)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Proxy.Module._load (internal/modules/cjs/loader.js:556:12)
    at Object.<anonymous> (C:\Users\[REDACTED]]\v12.6.0\node_modules\pm2\lib\ProcessContainerFork.js:27:21)
    at Module._compile (internal/modules/cjs/loader.js:776:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
    at Module.load (internal/modules/cjs/loader.js:643:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at internal/modules/esm/translators.js:87:15

@Andrey-Bushman
Copy link
Author

Andrey-Bushman commented Aug 14, 2019

Thank you, @sidvishnoi. How can I solve it? I see node hasn't --type parameter.

@sidvishnoi
Copy link

How can I solve it?

No idea. I'm reporting to support this issue to be fixed.

I see node hasn't --type parameter

Yes, there isn't. It has to be fixed at pm2 level.

@stale
Copy link

stale bot commented May 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label May 24, 2020
@stale stale bot closed this as completed Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants