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

does not provide an export named 'getTimezoneOffset' #2545

Closed
phcent opened this issue Mar 4, 2022 · 29 comments · Fixed by #2947
Closed

does not provide an export named 'getTimezoneOffset' #2545

phcent opened this issue Mar 4, 2022 · 29 comments · Fixed by #2947

Comments

@phcent
Copy link

phcent commented Mar 4, 2022

TuSimple/naive-ui version (版本)

2.26.0

Vue version (Vue 版本)

3.2.31

Browser and its version (浏览器及其版本)

Chrome(98.0.4758.102)

System and its version (系统及其版本)

Chrome(98.0.4758.102)

Node version (Node 版本)

Reappearance link (重现链接)

https://codesandbox.io/s/practical-northcutt-woeq78

Reappearance steps (重现步骤)

浏览器报错:Uncaught SyntaxError: The requested module '/_nuxt/node_modules/date-fns-tz/index.js?v=297527ff' does not provide an export named 'getTimezoneOffset'

Expected results (期望的结果)

没有错误

Actual results (实际的结果)

Uncaught SyntaxError: The requested module '/_nuxt/node_modules/date-fns-tz/index.js?v=297527ff' does not provide an export named 'getTimezoneOffset'

Remarks (补充说明)

@github-actions github-actions bot added the untriaged need to sort label Mar 4, 2022
@phcent
Copy link
Author

phcent commented Mar 4, 2022

/naive-ui/es/time/src/Time.js 第三行

@Sepush
Copy link
Collaborator

Sepush commented Mar 4, 2022

你的codesanbox复现跑不起来啊

@07akioni
Copy link
Collaborator

07akioni commented Mar 5, 2022

closed in #2555

@07akioni 07akioni closed this as completed Mar 5, 2022
@Sepush Sepush reopened this Mar 7, 2022
@phcent
Copy link
Author

phcent commented Mar 7, 2022

@07akioni
Copy link
Collaborator

07akioni commented Mar 8, 2022

image

没看出有啥问题

@07akioni
Copy link
Collaborator

07akioni commented Mar 8, 2022

有啥可以复现的仓库么

@07akioni
Copy link
Collaborator

07akioni commented Mar 8, 2022

我把 codesandbox 拉下来用 npm i 跑了一下

image

说实话我到现在为止从来没跑起来过任何一个直接拉下来的 nuxt 仓库,不下三次了,搞的每次为这个东西 debug 好像浪费时间一样

@Sepush Sepush added need reproduction and removed untriaged need to sort labels Mar 8, 2022
@phcent
Copy link
Author

phcent commented Mar 8, 2022

image

没看出有啥问题

将右侧的地址https://woeq78.sse.codesandbox.io/ 复制到浏览器打开 就能看见错误了 图片所示也是有异常的 幻灯片并不能切换 这个错误导致了 整个系统都不能正常使用哦 情况很严重呢

@Sepush
Copy link
Collaborator

Sepush commented Mar 8, 2022

image
没看出有啥问题

将右侧的地址https://woeq78.sse.codesandbox.io/ 复制到浏览器打开 就能看见错误了 图片所示也是有异常的 幻灯片并不能切换 这个错误导致了 整个系统都不能正常使用哦 情况很严重呢

这种bug 希望能给一个GitHub仓库地址 clone之后能跑起来的 这样方便我们debug 线上环境会有一些问题

@phcent
Copy link
Author

phcent commented Mar 8, 2022

image

@phcent
Copy link
Author

phcent commented Mar 9, 2022

https://github.com/phcent/navie-nuxt 项目地址 我测试是可以运行的

@leixuexxxx
Copy link

same problem here
Uncaught SyntaxError: The requested module '/_nuxt/node_modules/date-fns-tz/index.js?v=4a0bed47' does not provide an export named 'getTimezoneOffset'

@07akioni 07akioni reopened this Mar 15, 2022
@07akioni
Copy link
Collaborator

07akioni commented Mar 15, 2022

This is a nuxt bug, it doesn't transform common js index to a esm index. I don't know why.

If possible you can create an issue in nuxt repo.

这玩意就不能正常工作一下吗,佛了

@phcent
Copy link
Author

phcent commented Mar 29, 2022

@07

This is a nuxt bug, it doesn't transform common js index to a esm index. I don't know why.

If possible you can create an issue in nuxt repo.

这玩意就不能正常工作一下吗,佛了

es/time/src/Time.js
能将一下引用方式更改一下 来适应nuxt吗?
import { getTimezoneOffset } from 'date-fns-tz';
改成以下任意一种
import getTimezoneOffset from 'date-fns-tz/getTimezoneOffset';
import { getTimezoneOffset } from 'date-fns-tz/esm/getTimezoneOffset';

@07akioni
Copy link
Collaborator

@07

This is a nuxt bug, it doesn't transform common js index to a esm index. I don't know why.
If possible you can create an issue in nuxt repo.
这玩意就不能正常工作一下吗,佛了

es/time/src/Time.js 能将一下引用方式更改一下 来适应nuxt吗? import { getTimezoneOffset } from 'date-fns-tz'; 改成以下任意一种 import getTimezoneOffset from 'date-fns-tz/getTimezoneOffset'; import { getTimezoneOffset } from 'date-fns-tz/esm/getTimezoneOffset';

第一种具体啥问题我忘了,好像是打包会出问题
第二种和 CJS 不兼容,打包不了 CJS 兼容包

我都试过

@07akioni
Copy link
Collaborator

@07

This is a nuxt bug, it doesn't transform common js index to a esm index. I don't know why.
If possible you can create an issue in nuxt repo.
这玩意就不能正常工作一下吗,佛了

es/time/src/Time.js 能将一下引用方式更改一下 来适应nuxt吗? import { getTimezoneOffset } from 'date-fns-tz'; 改成以下任意一种 import getTimezoneOffset from 'date-fns-tz/getTimezoneOffset'; import { getTimezoneOffset } from 'date-fns-tz/esm/getTimezoneOffset';

这个 feature 应该是没开放出去,我看看没开出去的话下个版本先删了

@Baiyuetribe
Copy link
Contributor

same problem here Uncaught SyntaxError: The requested module '/_nuxt/node_modules/date-fns-tz/index.js?v=4a0bed47' does not provide an export named 'getTimezoneOffset'

这是因为你们的项目里nuxt3配置错误导致的,该问题早就修复了。这才是正确使用方式,https://github.com/Baiyuetribe/nuxt3-naive-ui-starter

@phcent
Copy link
Author

phcent commented Apr 2, 2022

same problem here Uncaught SyntaxError: The requested module '/_nuxt/node_modules/date-fns-tz/index.js?v=4a0bed47' does not provide an export named 'getTimezoneOffset'

这是因为你们的项目里nuxt3配置错误导致的,该问题早就修复了。这才是正确使用方式,https://github.com/Baiyuetribe/nuxt3-naive-ui-starter

你这是把naive排除在ssr渲染之外了

@phcent
Copy link
Author

phcent commented Apr 2, 2022

@Baiyuetribe 你先试试最新版本能不能跑起来 我用你的并没有跑起来

@Baiyuetribe
Copy link
Contributor

我都开发出了两个实际案例了,最小demo都给了,这demo还可以在线stackblitz上一键运行,到底是谁的问题?
案例1: 书籍系统 https://duhaoshu.cc
案例2:云盘资源分享网 https://www.aliyunpanziyuan.com
开源分享,完全没必要欺诈吧?

@07akioni
Copy link
Collaborator

07akioni commented Apr 6, 2022

https://github.com/Baiyuetribe/nuxt3-naive-ui-starter

倒不是你说的这样,他的配置没啥问题。

我暂时没空实验,推测是这样的逻辑:

vite 默认会把能外部化的依赖还是用外部的,比如说 naive 提供了 cjs 就去用 naive 的,不去再跑一次 vite 打包。

但是外部化的情况下 nuxt 这个玩意有 bug,导致爆了你说的这个问题。

或许 noExternal 恰好能处理这个问题。

https://cn.vitejs.dev/guide/ssr.html#ssr-externals

image

@phcent
Copy link
Author

phcent commented Apr 15, 2022

临时解决方案
es/time/src/Time.js
将以下引用方式
import { getTimezoneOffset } from 'date-fns-tz';
改成为下面
import getTimezoneOffset from 'date-fns-tz/getTimezoneOffset';
能解决目前的问题 记得清理浏览器缓存 不然依然会报错

@cinob
Copy link
Contributor

cinob commented Apr 21, 2022

遇到了相同的问题

@leixuexxxx
Copy link

我的解决办法是在app.vue里面 import { getTimezoneOffset } from 'date-fns-tz'
然后随便用一下

@07akioni
Copy link
Collaborator

遇到了相同的问题

这个 issue 是 nuxt 导致的,这边并没办法提供什么简单的方法去解决这个问题

@07akioni
Copy link
Collaborator

目前除了把这段源代码删掉以外办法不多,建议你们去 nuxt 那边提个 issue

@phcent
Copy link
Author

phcent commented Apr 22, 2022

@07akioni 大佬 改一下引用方式呢 下面的这种方法我确定可以解决问题
es/time/src/Time.js
将以下引用方式
import { getTimezoneOffset } from 'date-fns-tz';
改成为下面
import getTimezoneOffset from 'date-fns-tz/getTimezoneOffset';

@cinob
Copy link
Contributor

cinob commented May 10, 2022

大佬们 有什么更好的解决方案嘛 现在每次都得直接改Time.js里源码 有点难受啊

@07akioni
Copy link
Collaborator

大佬们 有什么更好的解决方案嘛 现在每次都得直接改Time.js里源码 有点难受啊

最好的办法是给 nuxt 提 issue,我最近确实没什么时间处理这个问题,如果今晚我解决不了那最早也得周末了

@07akioni 07akioni mentioned this issue May 15, 2022
07akioni added a commit that referenced this issue May 15, 2022
…oses #2545 (#2947)

* wip: date-fns esm

* wip: build script for date fns

* wip: fix build script

* wip: fix build script

* wip: fix build script

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

Successfully merging a pull request may close this issue.

6 participants