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')
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.
Most helpful comment
Hi there,
does anyone know if mjs and ES6 modules are now supported with pkg ?
Thank you for your help,
David.