Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest version of parse-ms 3.0.0 breaks common #5

Closed
markkoehn opened this issue Apr 9, 2021 · 2 comments
Closed

Latest version of parse-ms 3.0.0 breaks common #5

markkoehn opened this issue Apr 9, 2021 · 2 comments

Comments

@markkoehn
Copy link

We are using the mongoose-gridfs module, that has a dependency on lykmapipo/common. This version includes parse-ms with the following syntax in package.json: "parse-ms": ">=2.1.0"

Today - parse-me introduced version 3.0.0 of their code which breaks in index.js of common because they now require you to use the import command instead of the require command.

To stay compatible for other programs that depend on mongoose-gridfs and the like, if package.json instead used
"parse-ms": "2.1.0" this would not be a problem anymore.

The following code reproduces the problem:

const mongooseGridFs = require('mongoose-gridfs');

package.json has

"mongoose-gridfs": "1.2.48"

Using node 12.6.0 produces the following call stack:
export default function parseMilliseconds(milliseconds) {
^^^^^^

SyntaxError: Unexpected token export
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (/opt/subtask/node_modules/@lykmapipo/common/lib/index.js:18:27)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (/opt/subtask/node_modules/@lykmapipo/mongoose-common/index.js:31:47)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object. (/opt/subtask/node_modules/mongoose-gridfs/lib/schema.js:6:41)
at Module._compile (internal/modules/cjs/loader.js:776:30)

Using node 13.2.0 produces the following call stack:

(node:259) Warning: require() of ES modules is not supported.
require() of /opt/subtask/node_modules/parse-ms/index.js from /opt/subtask/node_modules/@lykmapipo/common/lib/index.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename /opt/subtask/node_modules/parse-ms/index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /opt/subtask/node_modules/parse-ms/package.json.
internal/modules/cjs/loader.js:1156
throw new ERR_REQUIRE_ESM(filename);
^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /opt/subtask/node_modules/parse-ms/index.js
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1156:13)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at Object. (/opt/subtask/node_modules/@lykmapipo/common/lib/index.js:18:27)
at Module._compile (internal/modules/cjs/loader.js:1121:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32)
at Function.Module._load (internal/modules/cjs/loader.js:884:14)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at Object. (/opt/subtask/node_modules/@lykmapipo/mongoose-common/index.js:31:47)
at Module._compile (internal/modules/cjs/loader.js:1121:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1160:10)
at Module.load (internal/modules/cjs/loader.js:976:32) {
code: 'ERR_REQUIRE_ESM'
}

Thank you for your help.

@lykmapipo
Copy link
Owner

@markkoehn Thanks. Am on it.

@Katochimoto
Copy link

Looks like the same problem with parse-json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants