es6-node-module

raw JSON →
0.1.0 verified Fri May 01 auth: no javascript abandoned

An early experimental library for describing Node.js modules using ES6 module notation and transpiling them to CommonJS. Version 0.1.0 is the initial release. It resolves local and npm imports. This project is an early prototype from 2014 and has not seen updates; it is effectively abandoned. Key differentiator: allows authoring ES6 modules and transpiles to ES5 CommonJS, but predates modern standards like Babel.

error Error: Cannot find module 'es6-node-module'
cause Package is very old and may need npm install with --legacy-peer-deps
fix
npm install es6-node-module --save --legacy-peer-deps
deprecated Package is no longer maintained and does not support modern ES6/ES2015+ syntax.
fix Use modern tools like Babel, SWC, or esbuild instead.
gotcha The package is not compatible with Node.js >=14; engine requirement is >=0.10.0 but may fail on newer Node versions.
fix Use Node.js 0.10.x – 0.12.x, or avoid this package.
npm install es6-node-module
yarn add es6-node-module
pnpm add es6-node-module

Shows how to load a NodePackage, retrieve a module, transpile to CJS, and get recursive dependencies.

const { NodePackage, getDependencies } = require('es6-node-module');

const nodePackage = new NodePackage('/some/node/path');
const utilModule = nodePackage.getModule('./lib/util');

console.log(utilModule.fullPath);
console.log(utilModule.src);
console.log(utilModule.toCJSString());

const deps = getDependencies(true, false, utilModule);
deps.forEach(dep => console.log(dep.fullPath));