Adapter "cannot find module" as of upgrade to recent version
See original GitHub issueDescribe 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:
- Created 2 years ago
- Comments:8 (4 by maintainers)
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?
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 usingtype: module
, they should useexports
to support theol/Feature
syntax, otherwiseol/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.