Sveltekit - 500 进程未定义或导出未定义

问题描述

我正在尝试从 sveltekit (svelteKit v1.0.0-next.114) 应用程序调用 GRPC 服务(dGraph api)。

我正在使用来自 writablesvelte/store 存储,并且能够将调用 GRPC 服务的响应记录到控制台。

但是,我们将 store 导入到我的 svelte 组件中,使用以下命令,我收到以下错误

 <script>
    import {resume_store} from '../../stores/resume';
    console.log($resume_store);
 </script>

错误

500

process is not defined

node_modules/@grpc/grpc-js/build/src/logging.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:9012:28
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/@grpc/grpc-js/build/src/Metadata.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:9057:21
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/@grpc/grpc-js/build/src/call-credentials.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:9231:22
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/@grpc/grpc-js/build/src/index.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:15325:30
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/dgraph-js/lib/util.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:15483:16
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/dgraph-js/lib/types.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:15595:18
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/dgraph-js/lib/dgraph.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:17224:15
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
node_modules/dgraph-js/lib/index.js@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:17254:18
__require@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:7:44
@http://localhost:3000/node_modules/.vite/dgraph-js.js?v=d2c49382:17261:25

替代 Dqraph 客户端

我也尝试使用 dgraph-js-http 客户端。

观察结果(见下文)是相同的 - 有一小段时间页面看起来符合预期。

首先,我收到一个错误,看起来与 https://github.com/vitejs/vite/issues/2579 中描述的一样。但是,我没有保存这个,所以不能在这里粘贴确切的错误

然后我尝试了

  1. 删除 node_modules
  2. 正在运行 npm install
  3. 正在运行 npm dev run

然后,然而发生了以下错误

错误 - Buffer2 未定义


500

Buffer2 is undefined

node_modules/safe-buffer/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:554:9
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
node_modules/jws/lib/sign-stream.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:1126:19
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
node_modules/jws/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:1306:22
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
node_modules/jsonwebtoken/decode.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:1339:15
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
node_modules/jsonwebtoken/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:3396:15
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
node_modules/dgraph-js-http/lib/clientStub.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:3598:15
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
node_modules/dgraph-js-http/lib/index.js@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:4587:18
__require@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:7:44
@http://localhost:3000/node_modules/.vite/dgraph-js-http.js?v=e33d301e:4595:30

其他尝试包括

观察

sveltekit 应用程序的网页有一小段时间显示了 dgraph grpc 服务调用的结果 - 也许一秒钟。然后显示上面的错误信息。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...