unfolding-io / nebulix

Nebulix, a Fast & Green Theme Based on Astro + Static CMS + Snipcart

Home Page:https://nebulix.unfolding.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

document is not defined error

theapplegates opened this issue · comments

commented

I'm afraid my developer skills end after Google fails me.

I get an error,

Browser APIs are not available on the server.

If the code is in a framework component, try to access these objects after rendering using lifecycle methods or use a client:only directive to make the component exclusively run on the client.

See  https://docs.astro.build/en/guides/troubleshooting/#document-or-window-is-not-defined  for more information.

ReferenceError: document is not defined
    at /home/parallels/Documents/nebulix/src/util/toLocale.ts:4:12
    at instantiateModule (file:///home/parallels/Documents/nebulix/node_modules/vite/dist/node/chunks/dep-df561101.js:55974:15)

I have tried this on a Mac, and a Windows VM, A fedora VM and all get the same error.

Loving the look and fit and finish. I would love it more if it worked for me haha

Paul

Hi Paul,
Did you set the language in the .env?
There is a env.txt you have to rename to .env.

Let me know if that fixes the problem

commented

Yes, I have it setup. I've seen it in other sites as en_us or en-us. You have it as en, so I kept it as en.

I just want a blog so according to the README I removed the files in content and pages and I have

 BLOG_SLUG= "blog",
 WEBSITE_LANGUAGE= "en",
 CURRENCY= "USD",
 UNITS= "metric",
 NODE_VERSION= "18",

env files dont need "" and ,
Please try:

BLOG_SLUG=blog
WEBSITE_LANGUAGE=en
CURRENCY=USD
UNITS=metric
NODE_VERSION=18

I have tested removing

- src/pages/menu
- src/pages/shop
- src/pages/work
- src/content/menu
- src/content/product
- src/content/project
- src/content/page/shop

This seems works on my computer :(
Can you try to run

$ npm run dev:demo

This will inject the env on build time

@theapplegates let me know if this works.

if not please send me a screenshot of the root folder, your env file and a complete error log.

Thanks

commented

The npm run dev:demo works until I click on an element that I deleted, such as a product.

I don't know where to get logs. Like console logs? Or errors in the terminal.


Node.js v18.17.1
thor3@Pauls-MacBook-Air nebulix-test % npm run build

> nebulix@0.1.2 build
> astro build

12:53:29 PM [content] The "menu" collection does not have an associated folder in your `content` directory. Make sure the folder exists, or check your content config for typos.
12:53:29 PM [content] The "project" collection does not have an associated folder in your `content` directory. Make sure the folder exists, or check your content config for typos.
12:53:29 PM [content] The "product" collection does not have an associated folder in your `content` directory. Make sure the folder exists, or check your content config for typos.
12:53:29 PM [content] Types generated 304ms
12:53:29 PM [build] output target: static
12:53:29 PM [build] Collecting build info...
12:53:29 PM [build] Completed in 509ms.
12:53:29 PM [build] Building static entrypoints...
The language "ENV" doesn't exist, falling back to plaintext.
node_modules/astro-icon/lib/utils.ts (2:9) "Props" is not exported by "node_modules/astro-icon/lib/Props.ts", imported by "node_modules/astro-icon/lib/utils.ts".
node_modules/astro-icon/lib/utils.ts (2:16) "Optimize" is not exported by "node_modules/astro-icon/lib/Props.ts", imported by "node_modules/astro-icon/lib/utils.ts".
12:53:31 PM [build] Completed in 2.08s.

 building client 
Completed in 433ms.


 generating static routes 
▶ src/pages/images/[slug].astro
  ├─ /images/about-us/index.html (+185ms)
  ├─ /images/cappuchinno/index.html (+5ms)
  ├─ /images/cosmic-aperol-spritz/index.html (+4ms)
  ├─ /images/cosmic-dark-and-stormy/index.html (+4ms)
  ├─ /images/cosmic_about_us/index.html (+7ms)
  ├─ /images/cosmic_blog_settings/index.html (+3ms)
  ├─ /images/cosmic_coctails_1/index.html (+2ms)
  ├─ /images/cosmic_coctails_3/index.html (+2ms)
  ├─ /images/cosmic_coffee/index.html (+3ms)
  ├─ /images/cosmic_coffee_2/index.html (+2ms)
  ├─ /images/cosmic_coffee_3/index.html (+2ms)
  ├─ /images/cosmic_coffee_4/index.html (+2ms)
  ├─ /images/cosmic_coffee_5/index.html (+2ms)
  ├─ /images/cosmic_contact_settings/index.html (+2ms)
  ├─ /images/cosmic_gin_tonic/index.html (+2ms)
  ├─ /images/cosmic_markdown_editor/index.html (+2ms)
  ├─ /images/cosmic_mojito/index.html (+4ms)
  ├─ /images/cosmic_moscow_mule/index.html (+2ms)
  ├─ /images/cosmic_navigation_settings/index.html (+2ms)
  ├─ /images/cosmic_news/index.html (+2ms)
  ├─ /images/cosmic_style_guide/index.html (+2ms)
  ├─ /images/cration_universe/index.html (+2ms)
  ├─ /images/dsc06460/index.html (+2ms)
  ├─ /images/embeds/index.html (+2ms)
  ├─ /images/ibiza/index.html (+2ms)
  ├─ /images/kitten_mug/index.html (+2ms)
  ├─ /images/lamborghini/index.html (+2ms)
  ├─ /images/licence/index.html (+2ms)
  ├─ /images/long-island-iced-tea/index.html (+2ms)
  ├─ /images/nebula_pluche-cat/index.html (+3ms)
  ├─ /images/nebula_pluche-cuty/index.html (+2ms)
  ├─ /images/nebula_pluche-drago/index.html (+2ms)
  ├─ /images/nebula_pluche-drago2/index.html (+2ms)
  ├─ /images/nebula_pluche-nebulix/index.html (+2ms)
  ├─ /images/nebula_pluche-wizy/index.html (+2ms)
  ├─ /images/nebulala_2/index.html (+2ms)
  ├─ /images/nebulala_3/index.html (+2ms)
  ├─ /images/nebulala_rocket/index.html (+2ms)
  ├─ /images/nebulala_seo/index.html (+2ms)
  ├─ /images/nebulix-ben-bag/index.html (+2ms)
  ├─ /images/nebulix-board-game/index.html (+2ms)
  ├─ /images/nebulix-bucket/index.html (+4ms)
  ├─ /images/nebulix-sneakers/index.html (+2ms)
  ├─ /images/nebulix-style/index.html (+2ms)
  ├─ /images/nebulix-template/index.html (+2ms)
  ├─ /images/nebulix-tshirt-2/index.html (+2ms)
  ├─ /images/nebulix_hoodie/index.html (+2ms)
  ├─ /images/nebulix_merch/index.html (+2ms)
  ├─ /images/nebulix_page_builder/index.html (+2ms)
  ├─ /images/nebulix_sneaker-2/index.html (+2ms)
  ├─ /images/nebulix_water_bottle/index.html (+2ms)
  ├─ /images/nebulix_water_cap-1/index.html (+2ms)
  ├─ /images/nebulix_water_cap-2/index.html (+2ms)
  ├─ /images/nebulixshop/index.html (+2ms)
  ├─ /images/nemulala/index.html (+2ms)
  ├─ /images/paper_cup/index.html (+3ms)
  ├─ /images/perfect_pagespeed_scores/index.html (+2ms)
  ├─ /images/plastic_cup/index.html (+1ms)
  ├─ /images/pluche_collection/index.html (+2ms)
  ├─ /images/project_a/index.html (+4ms)
  ├─ /images/project_b/index.html (+2ms)
  ├─ /images/project_c/index.html (+2ms)
  ├─ /images/project_d/index.html (+2ms)
  ├─ /images/project_e/index.html (+2ms)
  ├─ /images/project_f/index.html (+2ms)
  ├─ /images/project_website/index.html (+2ms)
  ├─ /images/roadmap/index.html (+3ms)
  ├─ /images/space_tutle/index.html (+2ms)
  ├─ /images/steel_mug/index.html (+4ms)
  └─ /images/t-shitrt-nebulix-3/index.html (+2ms)
▶ src/pages/admin.astro
  └─ /admin/index.html (+5ms)
▶ src/pages/blog/tag/[...slug].astro
[astro-imagetools]  data-astro-cid-v3xsbo6l  is not a valid Picture Config Option
Responsive Image sets generated for Picture at /src/assets/nebulix-style.jpeg in 33.567040998488665ms
Responsive Image sets generated for Picture at /src/assets/nebulala_rocket.jpeg in 35.06554099917412ms
Responsive Image sets generated for Picture at /src/assets/nebulix-template.jpeg in 36.44287499785423ms
Responsive Image sets generated for Picture at /src/assets/nebulix_page_builder.jpeg in 36.62262500077486ms
Responsive Image sets generated for Picture at /src/assets/roadmap.jpeg in 36.7597499974072ms
Responsive Image sets generated for Picture at /src/assets/cosmic_coffee_5.jpeg in 106.52199999988079ms
  ├─ /blog/tag/docs/index.html (+139ms)
[astro-imagetools]  data-astro-cid-v3xsbo6l  is not a valid Picture Config Option
Responsive Image sets generated for Picture at /src/assets/cosmic-aperol-spritz.jpeg in 25.262167003005743ms
  └─ /blog/tag/features/index.html (+46ms)
▶ src/pages/blog/[...slug].astro
count 5 0
count 5 1
count 5 2
count 5 3
count 5 4
[astro-imagetools]  data-astro-cid-v3xsbo6l  is not a valid Picture Config Option
Responsive Image sets generated for Picture at /src/assets/nebulala_rocket.jpeg in 17.69004200026393ms
  ├─ /blog/readme/index.html (+36ms)
[astro-imagetools]  data-astro-cid-v3xsbo6l  is not a valid Picture Config Option
Responsive Image sets generated for Picture at /src/assets/nebulix-style.jpeg in 15.754916001111269ms
  ├─ /blog/how-to-customize-the-theme/index.html (+30ms)
[astro-imagetools]  data-astro-cid-v3xsbo6l  is not a valid Picture Config Option
Responsive Image sets generated for Picture at /src/assets/nebulix-template.jpeg in 9.22358400002122ms
  ├─ /blog/templates-and-page-styles/index.html (+22ms)
[astro-imagetools]  data-astro-cid-nd3didwl  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nd3didwl  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nd3didwl  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nd3didwl  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nd3didwl  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nd3didwl  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-7uerxe52  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-7uerxe52  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-7uerxe52  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-7uerxe52  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-7uerxe52  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-7uerxe52  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nv7hfztk  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nv7hfztk  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nv7hfztk  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nv7hfztk  is not a valid Picture Config Option
[astro-imagetools]  data-astro-cid-nv7hfztk  is not a valid Picture Config Option
node:internal/process/promises:288
            triggerUncaughtException(err, true /* fromPromise */);
            ^

AstroError [CollectionDoesNotExistError]: The collection **product** does not exist. Ensure a collection directory with this name exists.
    at getCollection (file:///Users/thor3/Documents/nebulix-test/dist/chunks/pages/__b1f54c02.mjs:63:13)
    at file:///Users/thor3/Documents/nebulix-test/dist/chunks/pages/__b1f54c02.mjs:5155:22
    at AstroComponentInstance.ShopProducts [as factory] (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:202:12)
    at AstroComponentInstance.init (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:997:29)
    at AstroComponentInstance.render (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:1002:18)
    at Object.render (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:1453:22)
    at renderChild (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:960:17)
    at async Object.renderToFinalDestination (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:778:7)
    at async RenderTemplateResult.render (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:1072:9)
    at async renderChild (file:///Users/thor3/Documents/nebulix-test/dist/chunks/astro_095eaca7.mjs:960:5) {
  loc: undefined,
  title: 'Collection does not exist',
  hint: 'See https://docs.astro.build/en/guides/content-collections/ for more on creating collections.',
  frame: undefined,
  type: 'AstroError'
}

Node.js v18.17.1
thor3@Pauls-MacBook-Air nebulix-test
RootFolders

Sorry for being a trouble maker. I appreciate your time in helping me.

Thanks for your feedback!
I see the warning about the missing collections, in an update I will make this a bit smarter. But this should not be a breaking issue.

So everything works until you navigate to a deleted page?
Then you can remove the unused pages from the navigation.

in the CMS navigate to:
localhost:4321/admin/#/collections/config/entries/navigation

You can also edit the markdown:
src/content/config/navigation.mdx

That the site works with the npm run dev:demo but not with npm run dev means that the .env file is not read by the app. I am not working on IOS so I dont know how to help with that.

You can just use the command and edit the env in the script file.

if you want to change some values, open the package.json file and under scripts you will find:

"dev:demo": "cross-env BLOG_SLUG=blog PORTFOLIO_SLUG=work SHOP_SLUG=shop MENU_SLUG=menu WEBSITE_LANGUAGE=en CURRENCY=USD UNITS=metric NODE_VERSION=18 SNIPCART_KEY=key astro dev"
commented

Yes, clicking on a deleted section/object leads to failure. You’ve given me options to make it work, so I’m satisfied. Computers are funny. My mind thinks that I have a copy you have but the outcome is different, it works for 99%, I’m finally a 1%’er.
Sounds like a good plan moving forward.
I’m going to close this case.
Thanks for the help.
Paul

I should have searched here earlier. I removed Shop/Product and Menu too, but the app kept dying in the blog area where I had a few original pages remaining. Totally made my head spin for a bit.

The interesting thing was that it crashed when I hovered over "Building your page with blocks" in the blog list! Hovering over the others was fine, but I took a look at that page and assume it's because of the contained block "Shop Products" is referenced.

Small sacrifice for such a great product!

@jpollone thanks!
I will look if I can create some build guards in the future.
Build failures are hard to debug. I had a similar error this morning, where a client removed an image from the repo resulting in a build failure without telling me what image was missing.