diff --git a/docs/history.md b/docs/history.md index 62776d2abd..fdef20f18f 100644 --- a/docs/history.md +++ b/docs/history.md @@ -77,6 +77,9 @@ Read our [Migration Guide](https://guide.meteor.com/2.7-migration.html) for this * `google-oauth@1.4.2` - Migrate from `http` to `fetch` +* `modules-runtime@0.13.0` + - Fix some npm modules being imported as an empty object. [PR](https://github.com/meteor/meteor/pull/11954), [Issue 1](https://github.com/meteor/meteor/issues/11900), [Issue 2](https://github.com/meteor/meteor/issues/11853). + #### Independent Releases ## v2.6.1, 2022-02-18 diff --git a/packages/modules-runtime/package.js b/packages/modules-runtime/package.js index df87a99e7b..c61c0e9e5c 100644 --- a/packages/modules-runtime/package.js +++ b/packages/modules-runtime/package.js @@ -1,6 +1,6 @@ Package.describe({ name: "modules-runtime", - version: "0.12.0", + version: "0.13.0-rc270.0", summary: "CommonJS module system", git: "https://github.com/benjamn/install", documentation: "README.md" diff --git a/packages/modules-runtime/server.js b/packages/modules-runtime/server.js index af70093a64..018a61e49b 100644 --- a/packages/modules-runtime/server.js +++ b/packages/modules-runtime/server.js @@ -51,6 +51,15 @@ Module.prototype.useNode = function () { throw new Error('npmRequire must be defined to use useNode'); } + try { + npmRequire.resolve(this.id); + } catch (e) { + throw new Error( + `Cannot find module "${this.id}". ` + + `Try installing the npm package or make sure it is not a devDependency.` + ); + } + // See tools/static-assets/server/npm-require.js for the implementation // of npmRequire. Note that this strategy fails when importing ESM // modules (typically, a .js file in a package with "type": "module" in