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

Error: Cannot find module 'core-js/modules/es.string.replace.js' #1194

Open
abdirahmn1 opened this issue Apr 18, 2024 · 16 comments
Open

Error: Cannot find module 'core-js/modules/es.string.replace.js' #1194

abdirahmn1 opened this issue Apr 18, 2024 · 16 comments
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@abdirahmn1
Copy link

Am encountering the error code MODULE_NOT_FOUND after updating the package to latest/@3.4.0, this didn't exist about 3 weeks ago. It seems to be a problem with core-js missing, temporarilly installing core-js seems to solve the problem.

Environment details

  1. Specify the API: Not API specific problem.
  2. OS type and version: Linux Mint 21.2 x86_64
  3. Library version and other environment information: lib version is @3.4.0

Steps to reproduce

  1. npm install @googlemaps/google-maps-services-js
  2. instanciate a new client
  3. simply run it

Code example

import { Client } from "@googlemaps/google-maps-services-js";
const newGmapsClient = new Client();
export default newGmapsClient;

Stack trace

node:internal/modules/cjs/loader:1077
  const err = new Error(message);
              ^

Error: Cannot find module 'core-js/modules/es.string.replace.js'
Require stack:
- /<work_dir>/node_modules/@googlemaps/url-signature/dist/index.umd.js
- /<work_dir>/node_modules/@googlemaps/google-maps-services-js/dist/serialize.js
- /<work_dir>/node_modules/@googlemaps/google-maps-services-js/dist/directions.js
- /<work_dir>/node_modules/@googlemaps/google-maps-services-js/dist/client.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
    at Module._load (node:internal/modules/cjs/loader:922:27)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:121:18)
    at /<work_dir>/node_modules/@googlemaps/url-signature/dist/index.umd.js:1:79
    at Object.<anonymous> (/<work_dir>/node_modules/@googlemaps/url-signature/dist/index.umd.js:1:807)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/<work_dir>/node_modules/@googlemaps/url-signature/dist/index.umd.js',
    '/<work_dir>/node_modules/@googlemaps/google-maps-services-js/dist/serialize.js',
    '/<work_dir>/node_modules/@googlemaps/google-maps-services-js/dist/directions.js',
    '/<work_dir>/node_modules/@googlemaps/google-maps-services-js/dist/client.js'
  ]
}

Node.js v18.17.1

Hopefully this gets fixed soon. 👍

@abdirahmn1 abdirahmn1 added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 18, 2024
@wangela
Copy link
Member

wangela commented Apr 18, 2024

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@abdirahmn1 Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

@justAsascha
Copy link

Same error on node v20 and osx

@victorighalo
Copy link

Same error on node v20 and osx

Found a solution?

@abdirahmn1
Copy link
Author

Same error on node v20 and osx

Found a solution?

You can simply npm install --save [email protected] to get rid of the problem temporarily

@ArturAmpilogov
Copy link

Another solution is to add the following code to the package.json:

"overrides": {
    "@googlemaps/url-signature": "1.0.32"
}

@yerycs
Copy link

yerycs commented Apr 19, 2024

Why don't maintainers create patch version to fix this issue? It is so discouragement to face error at the first time rather than getting response for GOOGLE MAP official sdk.

@justAsascha
Copy link

Why don't maintainers create patch version to fix this issue? It is so discouragement to face error at the first time rather than getting response for GOOGLE MAP official sdk.

Feel free to contribute. It's open source :)

@jcardenaslie
Copy link

Same error on node v20 and osx

Found a solution?

You can simply npm install --save [email protected] to get rid of the problem temporarily

This worked for me

@TimJohns
Copy link

"Technically" this is a dupe of #1182, which was closed, but I'd recommend keeping this one open until the upstream releases are fixed, so that it's easier for folks to find this, and not open additional new issues.

In any case, despite the fact that google-maps-services-js is featured prominently in the call stack, 1.0.33 release requires core-js but states no dependency #528 is a little closer to the root cause, and might be a good place for additional upvotes and commentary.

In terms of @justAsascha's recommendation to make a contribution since it's Open Source, I took a full day to take a crack at it, and if I tracked it down correctly, I believe the issue is that in js-url-signature, babel is determining that core-js is required for a couple of polyfills (including es.string.replace) for older browser support. I removed core-js from the .babelrc and it all worked great FOR ME (Nodejs 20 environment), but that's pretty clearly a build config/release business decision more than a code fix. In my own personal opinion, completely removing the core-js dependency is slightly preferable, since older browsers could still use older versions explicitly, and the rest of us would have one less dependency, but that's definitely a business decision.

I conjecture someone could alternately move core-js from devDependencies to dependencies in the package.json for js-url-signature; but I didn't try that. If anyone does, tag me in the PR and I'm happy to pull it down and test here, comment, etc. Or if I run out of stuff to do and can spare another day (ha!) I'll take another crack at it.

Based on 1.0.33 release requires core-js but states no dependency #528, it sounds like folks are aware of it, but not sure who owns that decision. I recommend upvoting there.

@arpithindukuri
Copy link

This answer works if you don't want to install a specific version as suggested above.
https://stackoverflow.com/a/72555437/14804912

After searching a lot, what works for me was what I found in this blog post:

https://blog.csdn.net/Missbelover/article/details/123221351

Basically, what you need to do is...

Remove all your node_modules dependencies.
npm rm -rf node_modules

Install core-js first.
npm install --save core-js

Finally install everything else.
npm install
yarn install

After this everything should work as expected, a least for me is working now.

Have a good day!

Thanks to Gustavo Villarroel C from Stack Overflow!

@zackdotcomputer
Copy link

zackdotcomputer commented Jun 19, 2024

There has been a PR to fix this issue in the underlying package here since early May. Unfortunately, there appears to be limited activity in that package compared to this one. I would encourage giving this Issue a 👍 so that a review of that PR gets prioritized, as this is breaking the upgrade path for this library for some folks.

(Edit: I meant to give the 👍 to the first post here - the issue itself. Google has in the past said they prioritize by those emoji on the top post.)

@davidbonan
Copy link

There has been a PR to fix this issue in the underlying package here since early May. Unfortunately, there appears to be limited activity in that package compared to this one. I would encourage giving this Issue a 👍 so that a review of that PR gets prioritized, as this is breaking the upgrade path for this library for some folks.

👍

@uriva
Copy link

uriva commented Jun 23, 2024

for deno users - npm:@googlemaps/[email protected] works for me

@TimJohns
Copy link

Looks like a new @googlemaps/url-signature (1.0.35) was released last night, but appears it did not include @zackdotcomputer's PR and still shows the issue in my environment. 1.0.33 release requires core-js but states no dependency #528:

Error: Cannot find module 'core-js/modules/es.string.replace.js'
Require stack:
- /Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/url-signature/dist/index.umd.js
- /Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/google-maps-services-js/dist/serialize.js
- /Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/google-maps-services-js/dist/directions.js
- /Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/google-maps-services-js/dist/client.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at /Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/url-signature/dist/index.umd.js:1:79
    at Object.<anonymous> (/Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/url-signature/dist/index.umd.js:1:807)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/url-signature/dist/index.umd.js',
    '/Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/google-maps-services-js/dist/serialize.js',
    '/Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/google-maps-services-js/dist/directions.js',
    '/Users/tjohns/Src/epic-roadtrip-planner/node_modules/@googlemaps/google-maps-services-js/dist/client.js'
  ]
}

Node.js v21.2.0

From package-lock.json:

    "node_modules/@googlemaps/url-signature": {
      "version": "1.0.35",
      "resolved": "https://registry.npmjs.org/@googlemaps/url-signature/-/url-signature-1.0.35.tgz",
      "integrity": "sha512-UvDUghW8bJTVSGb0G4j2eEIsUWCdVXRZlhxeCT/ZmG44lebW85v716L0ExO/m1or2DKswsZ+Bx6UUwSHDDHsIw==",
      "dependencies": {
        "crypto-js": "^4.2.0"
      }
    },

@ghayward
Copy link

Only way I've been able to get this to deploy is by switching to the deprecated Google Maps

npm uninstall @googlemaps/google-maps-services-js

npm install @google/maps

I'm not sure if this is advisable, but wanted to add this data point.

Very interested in better understanding what's going on here

@TimJohns
Copy link

TimJohns commented Aug 2, 2024

FYI - I'm no longer seeing the error in my environment as of the 1.0.36 release of @googlemaps/url-signature

From my latest package-lock.json:

    "node_modules/@googlemaps/url-signature": {
      "version": "1.0.36",
      "resolved": "https://registry.npmjs.org/@googlemaps/url-signature/-/url-signature-1.0.36.tgz",
      "integrity": "sha512-BTYFuGr+DRziXiHUR0xok4t2C8apTL2plSi/ouB7yVAPxv5qiHJ05v0gO98kXfhj4r63J1ZDNku65nH/GH9T0A==",
      "dependencies": {
        "crypto-js": "^4.2.0"
      }
    },

Cross-posted from 1.0.33 release requires core-js but states no dependency #528:

I now have no overrides or core-js in my package.json. I attempted to repro in Node v21.2.0 (where I most recently confirmed I was still seeing it) and v22.4.1 (npm v10.8.1), my current environment. I'm still tying to track down the specific change that may have resolved this for me, but I'm currently lost in the details of the latest babel environment updates, and I got a little excited, so figured I'd jump over here and add a comment here real quick before digging in further.

Can anyone confirm this is resolved and/or have details of what theoretically resolved it? Fingers crossed (and thanks!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests