pkg with ES Modules

Created on 8 Oct 2017  路  6Comments  路  Source: vercel/pkg

Does pkg support ESModules with the .mjs extension? Here is the command I'm running

pkg . --targets latest-macos-x64

I am seeing the following error:
Error [ERR_MISSING_MODULE]: Cannot find module ./main.mjs

my entry point or bin file is a standard .js file that imports the .mjs file like this:

#!/usr/local/bin/node
require = require('@std/esm')(module)
module.exports = require('./main.mjs')

Most helpful comment

Hi there,
does anyone know if mjs and ES6 modules are now supported with pkg ?
Thank you for your help,
David.

All 6 comments

the entire source is here: https://github.com/msell/nfl-odds-cli
My pkg command is in the npm scripts

I learned in the Zeit Community slack channel:

pkg relies on https://github.com/zeit/pkg-fetch which come with prepackaged node.js version. The latest in the project is v8.3.0
I guess I'll just keep an eye on it and wait for it to become available.

Currently the latest is 8.6.0. Just pass -t node8.6.0 as cli argument. However mjs is not supported yet.

Hi there,
does anyone know if mjs and ES6 modules are now supported with pkg ?
Thank you for your help,
David.

@msell Please re-open this. pkg-fetch is no longer a road blocker, we should start to work in pkg to support ES modules.

I came across this today and found #439 to be related.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

j-brown picture j-brown  路  4Comments

ksmithut picture ksmithut  路  4Comments

telunc picture telunc  路  4Comments

Nilesh0101 picture Nilesh0101  路  4Comments

bergheim picture bergheim  路  3Comments