导入温斯顿导致“进程未定义”

mun*_*ger 5 javascript winston svelte sveltekit

我正在使用 sveltekit 创建一个应用程序,目前正在添加日志记录。

温斯顿的后端非常简单,因为它几乎开箱即用。

但我在前端导入它时遇到了一些问题。

我的代码很简单

<script>
    import winston from 'winston';
    import { Card } from '../components/issue/';

    export let project;
</script>
Run Code Online (Sandbox Code Playgroud)

但这个简单的片段似乎引发了这个错误

500
process is not defined

ReferenceError: process is not defined
    at node_modules/colors/lib/system/supports-colors.js (http://localhost:3000/node_modules/.vite/winston.js?v=b8878498:281:15)
    at __require (http://localhost:3000/node_modules/.vite/chunk-JAKTRAE2.js?v=b8878498:6:44)
    at node_modules/colors/lib/colors.js (http://localhost:3000/node_modules/.vite/winston.js?v=b8878498:714:28)
    at __require (http://localhost:3000/node_modules/.vite/chunk-JAKTRAE2.js?v=b8878498:6:44)
    at node_modules/colors/safe.js (http://localhost:3000/node_modules/.vite/winston.js?v=b8878498:850:18)
    at __require (http://localhost:3000/node_modules/.vite/chunk-JAKTRAE2.js?v=b8878498:6:44)
    at node_modules/logform/dist/colorize.js (http://localhost:3000/node_modules/.vite/winston.js?v=b8878498:881:18)
    at __require (http://localhost:3000/node_modules/.vite/chunk-JAKTRAE2.js?v=b8878498:6:44)
    at node_modules/logform/dist/levels.js (http://localhost:3000/node_modules/.vite/winston.js?v=b8878498:953:20)
    at __require (http://localhost:3000/node_modules/.vite/chunk-JAKTRAE2.js?v=b8878498:6:44)
Run Code Online (Sandbox Code Playgroud)

老实说,我真的不知道可能出了什么问题,除了可能是服务器/客户端渲染的问题。

所以我想问题是:你可以在 sveltekit 项目中导入 Winston 吗?如果可以的话如何导入?这个具体问题有什么解决方法吗?