目录导航
- 撤销(Ctrl+Z)
- 重做(Ctrl+Y)
- 清空
- H 标题(Ctrl+1~6)
- 一级标题
- 二级标题
- 三级标题
- 四级标题
- 五级标题
- 六级标题
- 插入提示
- 提示
- 注意
- 警告
- 详细信息
- 粗体(Ctrl+B)
- 斜体(Ctrl+I)
- 删除线
- 插入引用(Ctrl+Q)
- 无序列表(Ctrl+U)
- 有序列表(Ctrl+O)
- 表格
- 插入分割线
- 插入链接(Ctrl+L)
- 插入图片
- 添加图片链接
- 插入代码块
- 关闭同步滚动
- 全屏(按ESC还原)
- 开启预览
<div class="markdown_body"><p>求解这个错误是什么原因导致的</p> <p>github 上找的 blog 程序,本地运行正常,可以正常 build 输出,但是在 vercel cloudflare 这些平台上就报下面的错误,node 版本也设置了不行。</p> <p>好像经常碰到 node-fetch 类的问题</p> <pre><code> error [vite]: Rollup failed to resolve import "node-fetch" from "/vercel/path0/src/lib/blog-helpers.ts". 22:49:46.923 This is most likely unintended because it can break your application at runtime. 22:49:46.923 If you do want to externalize this module explicitly add it to 22:49:46.924 `build.rollupOptions.external` 22:49:46.924 Error: [vite]: Rollup failed to resolve import "node-fetch" from "/vercel/path0/src/lib/blog-helpers.ts". 22:49:46.924 This is most likely unintended because it can break your application at runtime. 22:49:46.924 If you do want to externalize this module explicitly add it to 22:49:46.924 `build.rollupOptions.external` 22:49:46.924 at viteWarn (file:///vercel/path0/node_modules/.pnpm/vite@4.5.3/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48216:27) 22:49:46.924 at onRollupWarning (file:///vercel/path0/node_modules/.pnpm/vite@4.5.3/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48248:9) ```</code></pre> </div>
求解这个错误是什么原因导致的
github 上找的 blog 程序,本地运行正常,可以正常 build 输出,但是在 vercel cloudflare 这些平台上就报下面的错误,node 版本也设置了不行。
好像经常碰到 node-fetch 类的问题
error [vite]: Rollup failed to resolve import "node-fetch" from "/vercel/path0/src/lib/blog-helpers.ts".
22:49:46.923
This is most likely unintended because it can break your application at runtime.
22:49:46.923
If you do want to externalize this module explicitly add it to
22:49:46.924
`build.rollupOptions.external`
22:49:46.924
Error: [vite]: Rollup failed to resolve import "node-fetch" from "/vercel/path0/src/lib/blog-helpers.ts".
22:49:46.924
This is most likely unintended because it can break your application at runtime.
22:49:46.924
If you do want to externalize this module explicitly add it to
22:49:46.924
`build.rollupOptions.external`
22:49:46.924
at viteWarn (file:///vercel/path0/node_modules/.pnpm/vite@4.5.3/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48216:27)
22:49:46.924
at onRollupWarning (file:///vercel/path0/node_modules/.pnpm/vite@4.5.3/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:48248:9)
```
user2 • • 目录导航
|
如果你使用的是 https://github.com/otoyo/astro-notion-blog/blob/main/src/lib/blog-helpers.ts
如果不是当我没说
这个仓库有使用原生 fetch 替换 node-fetch 的 commit 的记录,但是没替换完全
根据 https://github.com/otoyo/astro-notion-blog/blob/main/package-lock.json 可以知道
node-fetch 并没有直接声明,是作为 @notionhq/client 的幽灵依赖提升使用的,幽灵依赖和包管理器有关
最简单的方法是 注释 掉上面那个 blog-helpers.ts 的第一行代码