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

🐛[BUG]Uncaught ReferenceError: process is not defined #6164

Closed
xezzon opened this issue Nov 4, 2022 · 11 comments
Closed

🐛[BUG]Uncaught ReferenceError: process is not defined #6164

xezzon opened this issue Nov 4, 2022 · 11 comments

Comments

@xezzon
Copy link

xezzon commented Nov 4, 2022

🐛 bug 描述

Uncaught ReferenceError: process is not defined
    at openVisibleCompatible2 (openVisibleCompatible.js:5:31)
    at SiderMenuWrapper2 (index.js:51:25)
    at renderWithHooks (react-dom.development.js:16305:18)
    at mountIndeterminateComponent (react-dom.development.js:20074:13)
    at beginWork (react-dom.development.js:21587:16)
    at HTMLUnknownElement.callCallback2 (react-dom.development.js:4164:14)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:4213:16)
    at invokeGuardedCallback (react-dom.development.js:4277:31)
    at beginWork$1 (react-dom.development.js:27451:7)
    at performUnitOfWork (react-dom.development.js:26557:12)

📷 复现步骤

命令行运行 vite

🏞 期望结果

正常渲染 ProLayout

💻 复现代码

function App() {
  const { pathname } = useLocation()
  const main = useRoutes(route.routes)

  return (
    <ProLayout
      layout="mix"
      fixSiderbar
      fixHeader
      route={route}
      location={{ pathname }}
      menu={{ autoClose: false }}
      menuItemRender={(item, dom) => <Link to={item.path}>{dom}</Link>}
      className="min-vh-100"
    >
      {main}
    </ProLayout>
  )
}

© 版本信息

  • ProComponents 版本: 2.3.28
  • Ant Design 版本: 4.24.0
  • node 版本: v18.12.0
  • vite 版本: 3.2.2
  • pnpm 版本: 7.14.2
  • 浏览器环境 Microsoft Edge 版本 107.0.1418.26 (正式版本) (64 位)
  • 开发环境 Windows 11

🚑 其他信息

@xezzon
Copy link
Author

xezzon commented Nov 4, 2022

compareVersions(process.env.ANTD_VERSION || version, '4.23.0') > -1

@Kaby-Lake
Copy link

同样的问题,在webpack下也出现了

@macjohson
Copy link

vite.config.ts 下加入

define: {
    'process.env': {}
  }

@nhatncb
Copy link

nhatncb commented Nov 6, 2022

vite.config.ts 下加入

define: {
    'process.env': {}
  }

This will lead to another bug related to useSWR

@Jungzl
Copy link
Contributor

Jungzl commented Nov 7, 2022

// vite.config.ts

import { version } from 'antd'

export default defineConfig(() => ({
  define: {
    'process.env.ANTD_VERSION': `"${version}"`,
  }
}))

@xezzon
Copy link
Author

xezzon commented Nov 8, 2022

用户侧处理不太友好吧?能不能从代码层面解决,比如链式操作符。

@Lucien-X
Copy link

用户侧处理不太友好吧?能不能从代码层面解决,比如链式操作符。

Same issue here...
我还以为vite出问题了,升了个vite版本还是这个问题

@abdeljalil09
Copy link

this bug has come back

@abdeljalil09
Copy link

// vite.config.ts

import { version } from 'antd'

export default defineConfig(() => ({
  define: {
    'process.env.ANTD_VERSION': `"${version}"`,
  }
}))

this work only in dev mode when shipping to production it comes back again

@abdeljalil09
Copy link

package is fully broken

@abdeljalil09
Copy link

this is my workaround the problem because the above work only in dev mode , to make it work in production

image

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

No branches or pull requests

7 participants