question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Adapter "cannot find module" as of upgrade to recent version

See original GitHub issue

Describe the bug

I have an error that has cropped up in @sveltejs/kit@1.0.0-next.202 and @sveltejs/adapter-node@1.0.0-next.56. I have a component that uses an OpenLayers map and I get the following from the adapter portion of the build:

Run npm run preview to preview your production build locally.

Using @sveltejs/adapter-node
Error [ERR_MODULE_NOT_FOUND]: Cannot find module '<monorepo_project>/node_modules/ol/Feature' imported from <monorepo_project>/packages/app/.svelte-kit/output/server/entries/pages/search.svelte.js
Did you mean to import ol/Feature.js?
    at new NodeError (node:internal/errors:371:5)
    at finalizeResolution (node:internal/modules/esm/resolve:416:11)
    at moduleResolve (node:internal/modules/esm/resolve:932:10)
    at defaultResolve (node:internal/modules/esm/resolve:1044:11)
    at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)

This worked as of 193/55, I first saw the error in 202/56, and still see it in 215/60. I do not think it is specific to that import, since if I remove it, it just complains about another file from OpenLayers instead. <monorepo_project>/node_modules/ol/Feature.js exists, so I do not know why it is having trouble finding that.

I should note that npm run dev works fine and does not complain about anything

Reproduction

See minimal reproduction at https://github.com/wallw-bits/svelte-kit-ol-issue-repro and npm i followed by npm run build.

Logs

No response

System Info

System:
    OS: Linux 5.11 Ubuntu 20.04.3 LTS (Focal Fossa)
    CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
    Memory: 6.19 GB / 31.11 GB
    Container: Yes
    Shell: 5.0.17 - /bin/bash
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.17 - ~/.nvm/versions/node/v16.13.0/bin/yarn
    npm: 7.24.2 - ~/workspace/saffire/ui/node_modules/.bin/npm
  Browsers:
    Chrome: 96.0.4664.110
    Firefox: 95.0.1
  npmPackages:
    @sveltejs/adapter-node: ^1.0.0-next.60 => 1.0.0-next.60 
    @sveltejs/kit: ^1.0.0-next.215 => 1.0.0-next.215 
    svelte: ^3.44.3 => 3.44.3

Severity

blocking an upgrade

Additional Information

No response

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wallw-tealcommented, Jan 4, 2022

Yup, I understand why that is not valid per the ES spec. However, why doesn’t the rest of the tooling have an issue with it?

0reactions
bluwycommented, Jan 5, 2022

Similar as https://github.com/vitejs/vite/issues/6193. But this is an issue within Openlayers itself, not Vite, as the error is coming from node. Since ol is using type: module, they should use exports to support the ol/Feature syntax, otherwise ol/Feature.js is required. I’m not sure how it used to work pre Vite 2.7 though, perhaps there were changes that surfaced the issue within Openlayers.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module '@angular/material-moment-adapter'
I was having issues running those commands but based on what you said about angular 5 being required I used the now updated...
Read more >
[Sveltekit v next.175+ with Netlify adapter] Cannot find module ...
Local builds still work, and Netlify builds work with version next.174. I have another Sveltekit project that runs on Vercel and I have...
Read more >
Issue while deploying sap cap based mta (Cannot find module ...
We are trying to use latest version of "@sap/cds-odata-v2-adapter-proxy" : "^9.1.15" with "@sap/cds": "^6.3.1", in one of our sap CAP ...
Read more >
Upgrade Guide (v4) - NextAuth.js
Upgrade Guide (v4). NextAuth.js version 4 includes a few breaking changes from the last major version (3.x). So we're here to help you ......
Read more >
Upgrading from AngularJS to Angular
AngularJS is the name for all 1.x versions of Angular. AngularJS applications are great. Always consider the business case before moving to Angular....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found