-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
script tag is giving could not import error #67
Comments
Hello @koolkunz I've been testing adding the Perhaps it is your version of Astro that is outdated, or some misreported error in one of the components that you import into your project. You can try cloning the latest version of AstroWind and add the contact-us.astro page with the |
Hi, thanks for the reply, it seems it is working for me if I build the project first and then run the preview using npm run build and npm run preview. But if I run the dev server directly using npm run dev it gives me the error. |
And I just tried cloning astrowind as a fresh project, and just added
to the end of the index.astro file and the error is still comming in npm run dev:
|
Thanks @koolkunz, we have made some progress. For me it works both at dev and build time. I have noticed that you use Windows, that is a difference, I use macOS. Can you please tell me what version of Node are you using? Thanks. |
My node version is v16.17.1 |
I have exactly the same error when importing astro-embed plugin. Mac OS, node is 14 |
Hi @delphinas It would be necessary to see the details of what happens when the |
Hi @prototypa did you find anything related to node? any other node version you can recommend that I should try? |
Hello @koolkunz Sorry for the delay. I've been doing some tests but I still can't find anything (and I haven't had much time to follow either). You can see a version of AstroWind on CodeSandox working with the following code in ---
import { SITE } from '~/config.mjs';
import { getCanonical, getHomePermalink } from '~/utils/permalinks';
import Layout from '~/layouts/PageLayout.astro';
import Hero from '~/components/widgets/Hero.astro';
import Note from '~/components/widgets/Note.astro';
import Features from '~/components/widgets/Features.astro';
import Features2 from '~/components/widgets/Features2.astro';
import Steps from '~/components/widgets/Steps.astro';
import Features3 from '~/components/widgets/Features3.astro';
import HighlightedPosts from '~/components/blog/HighlightedPosts.astro';
import FAQs from '~/components/widgets/FAQs.astro';
import Stats from '~/components/widgets/Stats.astro';
import CallToAction from '~/components/widgets/CallToAction.astro';
const meta = {
title: SITE.title,
description: SITE.description,
canonical: getCanonical(getHomePermalink()),
};
---
<Layout {meta}>
<Hero />
<Note />
<Features />
<Steps />
<Features2 />
<Features3 />
<HighlightedPosts />
<FAQs />
<Stats />
<CallToAction />
</Layout>
<script>
alert("Hello script!")
</script> -> https://codesandbox.io/s/busy-austin-z0lgf0?file=/src/pages/index.astro I really don't know what it will be. At the end of the week I will do new tests to see if I can simulate your environment and check the error because it works for me in my environment. |
@prototypa I have also tried using a different theme like https://github.com/mhyfritz/astro-landing-page and using script tag works fine with it on my system. So its not a problem with astro in general with my environment. |
@koolkunz there is a different between AstroWind and Astro Landing Page. Astro Landing Page (https://github.com/mhyfritz/astro-landing-page) don't use Layouts in Can you please test the script tag using Astro Ink template? https://github.com/one-aalam/astro-ink. Here in this file: https://github.com/one-aalam/astro-ink/blob/main/src/pages/index.astro Let me know, thanks. |
@prototypa You are on the right track, Astro Ink template also gives me a similar problem, the script tag on the BaseHead.astro file https://github.com/one-aalam/astro-ink/blob/main/src/components/BaseHead.astro gives the same error
If I remove the script tag it runs fine, and then if I add a script tag to index.astro the error is back. |
@prototypa I found the solution on astro official discord, it seems it's an issue caused by vite if we have any spaces in the project repo path, so simply changing my path from 'D:/DCS Projects/Local/astrowind' to 'D:/DCS-Projects/Local/astrowind' fixed the issue (replaced ' ' with '-'). Such a silly issue in the end. Thanks for all your help and support. I am closing the issue. |
Hey, I'm glad it's resolved. Thank you. |
Just adding a simple script tag which logs Hello to a page gives this error:
This is the .astro file for the page:
If I remove the script tag at the end the same page loads fine without any errors
The text was updated successfully, but these errors were encountered: