Mag*_*ick 5 node.js svelte dgraph grpc-node sveltekit
我正在尝试从 Sveltekit ( ) 应用程序调用 GRPC 服务(dGraph api)SvelteKit v1.0.0-next.114。
我正在使用writable的商店svelte/store,并且能够将调用 GRPC 服务的响应记录到控制台。
但是,我们使用以下命令将商店导入到我的 svelte 组件中,但出现以下错误。
<script>
import {resume_store} from '../../stores/resume';
console.log($resume_store);
</script>
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
我还尝试使用dgraph-js-http客户端。
观察结果(见下文)是相同的 - 即,页面在短时间内看起来符合预期。
首先,我收到一个错误,看起来与https://github.com/vitejs/vite/issues/2579上描述的相同。但是,我没有保存此内容,因此无法在此处粘贴确切的错误。
然后我尝试了
node_modulesnpm installnpm dev run然而,随后出现了以下错误。
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
Run Code Online (Sandbox Code Playgroud)
其他尝试包括:
export const hydrate = false;到.svelte文件中,但这没有什么区别。context="module"到<script>标签,因为这是与水合物相关的 Sveltekit 文档中显示的内容 - 请参阅https://kit.svelte.dev/docs#ssr-and-javascript-Hydrate。然而这导致了错误Cannot reference store value inside <script context="module">Sveltekit 应用程序的网页会短暂显示 dgraph grpc 服务调用的结果 - 可能有一秒钟。然后显示上面的错误消息。
| 归档时间: |
|
| 查看次数: |
2667 次 |
| 最近记录: |