-
Notifications
You must be signed in to change notification settings - Fork 128
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
Cannot find module .../node_modules/ol/Feature Did you mean to import "ol/Feature.js"? #358
Comments
I have the same issue
|
Check if you are not trying to render this component on the server side. |
I had the same error with nuxt 3. It can be solved in 2 ways:
export default defineNuxtConfig({
......
routeRules: {
'/sales': {ssr: false},
},
....
// sales.vue
<template>
<ClientOnly>
<SalesMap/>
</ClientOnly>
</template> // SalesMap.vue
<template>
<Map.OlMap style="min-width: 400px; min-height: 400px;">
<Map.OlView :center="[40, 40]" :zoom="5" projection="EPSG:4326"/>
<Layers.OlTileLayer>
<Sources.OlSourceOsm/>
</Layers.OlTileLayer>
</Map.OlMap>
</template>
<script lang="ts" setup>
import {Layers, Map, Sources} from 'vue3-openlayers'
</script> |
So in General, rendering the map, at server side does not make a lot of sense in my opinion, doesn't it? |
If you are using the plugin approach to import // nuxt.config.ts
plugins: [
{
src: '@/plugins/your-plugin-file-name-here',
mode: 'client'
}
] |
Describe the bug
Hello everyone!
I'm trying to integrate
vue3-openlayers
in my personal project.My stack is:
I'm trying to run this code:
But i got this error:
Cannot find module '/Users/fabrizio/Documents/Projects/TechCompenso/Repositories/tech-compenso/node_modules/.pnpm/vue3-openlayers@10.0.1_ol-contextmenu@5.4.0_ol@9.2.4__ol-ext@4.0.18_ol@9.2.4__ol@9.2.4_vue@3.4.27_typescript@5.4.5_/node_modules/ol/Feature' imported from /Users/fabrizio/Documents/Projects/TechCompenso/Repositories/tech-compenso/node_modules/.pnpm/vue3-openlayers@10.0.1_ol-contextmenu@5.4.0_ol@9.2.4__ol-ext@4.0.18_ol@9.2.4__ol@9.2.4_vue@3.4.27_typescript@5.4.5_/node_modules/vue3-openlayers/dist/vue3-openlayers.es.js Did you mean to import "ol/Feature.js"?
If i edit manually the import in the build and append
.js
it works. I think it's something related to thetsconfig.json
orastro
build.Consider that astro use vite for the building phase. So i can also do some tweaks on vite in the astro configuration if it is necessary.
These are respectively my
tsconfig.json
andastro.config.mjs
:tsconfig.json
astro.config.mjs
Affected version(s)
Expected behavior
It should not throw any error for the import.
I would really appreciate your help. Thank you very much.
The text was updated successfully, but these errors were encountered: