Skip to content
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

fix: fix TypeError when reading '__STORYBOOK__' property of undefined #539

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

baixiaoyu2997
Copy link
Contributor

@baixiaoyu2997 baixiaoyu2997 commented Apr 16, 2024

Close: #538

Copy link

netlify bot commented Apr 16, 2024

👷 Deploy request for nuxt-storybook pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit f055891

@NRodriguezcuellar
Copy link

To not switch back i think it would be better to use optional chaining to prevent errors when an env is not defined

import.meta.env?.__STORYBOOK__

@tobiasdiez
Copy link
Collaborator

To not switch back i think it would be better to use optional chaining to prevent errors when an env is not defined

import.meta.env?.__STORYBOOK__

I think this is indeed the better solution. @baixiaoyu2997 could you please give this a try?

@baixiaoyu2997
Copy link
Contributor Author

To not switch back i think it would be better to use optional chaining to prevent errors when an env is not defined

import.meta.env?.__STORYBOOK__

I think this is indeed the better solution. @baixiaoyu2997 could you please give this a try?

sorry, i don't understand, for my understanding import.meta.env?.__STORYBOOK__ always be undefined, because process.env is not equal to import.meta.env
image

@NRodriguezcuellar
Copy link

It is not exactly the same but serves the same purpose and has some security benefits when using Vite, you can read about it on here:

@tobiasdiez
Copy link
Collaborator

Yes,

process.env.__STORYBOOK__ = JSON.stringify( options )
needs to be changed as well to use import.meta.env

@baixiaoyu2997 baixiaoyu2997 changed the title fix: revert setup fix: __STROYBOOK__ env Apr 17, 2024
@baixiaoyu2997
Copy link
Contributor Author

thanks, guys, test on local, build success
image

@NRodriguezcuellar
Copy link

Great! Small typo in the title by the way 😃

@baixiaoyu2997 baixiaoyu2997 changed the title fix: __STROYBOOK__ env fix: __STORYBOOK__ env Apr 17, 2024
@tobiasdiez tobiasdiez changed the title fix: __STORYBOOK__ env fix: fix TypeError when reading '__STORYBOOK__' property of undefined Apr 19, 2024
@tobiasdiez tobiasdiez merged commit 98f007d into nuxt-modules:main Apr 19, 2024
1 check passed
@cannap
Copy link

cannap commented Apr 20, 2024

at checkExecSyncError (node:child_process:887:11)
at execSync (node:child_process:959:15)
at Object.run (/C:/Users/von%20mir/Desktop/offline-sync-demo/node_modules/nuxi/dist/chunks/upgrade.mjs:100:5)
at async runCommand$1 (/C:/Users/von%20mir/Desktop/offline-sync-demo/node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1648:16)
at async runCommand$1 (/C:/Users/von%20mir/Desktop/offline-sync-demo/node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1639:11)
at async runMain$1 (/C:/Users/von%20mir/Desktop/offline-sync-demo/node_modules/nuxi/dist/shared/nuxi.9edf0930.mjs:1777:7)

i get the same is use bun on windows

{
  "name": "nuxt-app",
  "private": true,
  "type": "module",
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev",
    "start": "node .output/server/index.mjs",
    "generate": "nuxt generate",
    "preview": "nuxt preview",
    "studio": "bunx drizzle-kit studio",
    "postinstall": "nuxt prepare"
  },
  "dependencies":  {
    "dotenv": "^16.4.5",
    "drizzle-orm": "^0.30.8",
    "lucia": "^3.1.1",
    "nuxt": "^3.11.2",
    "oslo": "^1.2.0",
    "pg": "^8.11.5",
    "postgres": "^3.4.4",
    "vue": "^3.4.21",
    "vue-router": "^4.3.0"
  },
  "devDependencies": {
    "@nuxt/devtools": "^1.2.0",
    "@nuxt/eslint": "^0.3.8",
    "@nuxtjs/storybook": "^8.0.0",
    "@nuxtjs/tailwindcss": "^6.12.0",
    "@types/pg": "^8.11.5",
    "@vite-pwa/nuxt": "^0.6.0",
    "@vueuse/nuxt": "^10.9.0",
    "drizzle-kit": "^0.20.16",
    "eslint": "^9.1.0"
  }
}

@9mm
Copy link

9mm commented Apr 21, 2024

when will this be released?

@AdamovichArtur
Copy link

Any ideas when the fixes will be released?

@chakAs3
Copy link
Collaborator

chakAs3 commented Jun 7, 2024

it is released sorry for the delay : https://github.com/nuxt-modules/storybook/releases/tag/v8.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[8.0.0]Cannot read properties of undefined (reading '__STORYBOOK__')
7 participants