【问题标题】:importing winston causes 'process is not defined'导入 winston 导致“未定义进程”
【发布时间】:2021-05-12 20:59:38
【问题描述】:

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

winston 的后端非常简单,因为它开箱即用。

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

我的代码很简单

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

    export let project;
</script>

但是那个简单的 sn-p 似乎会抛出这个错误

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)

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

所以我想问题是:您可以在 sveltekit 项目中导入 winston,如果可以,如何导入? 有没有针对这个特定问题的解决方法?

【问题讨论】:

  • winston 似乎是为 nodejs 制作的。

标签: javascript svelte winston sveltekit


【解决方案1】:

你现在是can't use Winston in the browser,虽然目前正在制定路线图支持它。

【讨论】:

    猜你喜欢
    • 2018-01-05
    • 2021-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-28
    • 1970-01-01
    相关资源
    最近更新 更多