The main field of your package.json points to index.js but it's internally is in ES6 format. I guess it will break npm expecting main to point to commonjs packages. Instead module field is proposed for ES6 modules and the extension is .mjs, so index.mjs.
I experiment with modules in Node v12 and currently this code:
// node --experimental-modules this-file.mjs
import LocalEchoController from 'local-echo';
throws:
.../node_modules/local-echo/index.js:1
import LocalEchoController from "./lib/LocalEchoController";
^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at Module._compile (internal/modules/cjs/loader.js:718:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at internal/modules/esm/translators.js:87:15
at Object.meta.done (internal/modules/esm/create_dynamic_module.js:45:9)
at file:///home/ilyaigpetrov/Projects/subterm/node_modules/local-echo/index.js:10:13
at ModuleJob.run (internal/modules/esm/module_job.js:111:37)
at async Loader.import (internal/modules/esm/loader.js:128:24)
The
main
field of yourpackage.json
points toindex.js
but it's internally is in ES6 format. I guess it will break npm expectingmain
to point to commonjs packages. Insteadmodule
field is proposed for ES6 modules and the extension is.mjs
, soindex.mjs
.I experiment with modules in Node v12 and currently this code:
throws: