导入 winston 导致 'process is not defined'
importing winston causes 'process is not defined'
我正在使用 sveltekit 创建一个应用程序,目前正在添加日志记录。
后端使用 winston 非常简单,因为它开箱即用。
但是我 运行 在前端导入它时遇到了一些问题。
我的代码很简单
<script>
import winston from 'winston';
import { Card } from '../components/issue/';
export let project;
</script>
但是这个简单的片段似乎会引发此错误
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)
老实说,除了可能是 server/client 侧渲染的问题外,我真的不知道还有什么问题。
所以我想问题是:您可以在 sveltekit 项目中导入 winston 吗?如果可以,如何导入?
这个具体问题有什么解决方法吗?
你现在can't use Winston in the browser,尽管目前在路线图上支持它。
我正在使用 sveltekit 创建一个应用程序,目前正在添加日志记录。
后端使用 winston 非常简单,因为它开箱即用。
但是我 运行 在前端导入它时遇到了一些问题。
我的代码很简单
<script>
import winston from 'winston';
import { Card } from '../components/issue/';
export let project;
</script>
但是这个简单的片段似乎会引发此错误
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)
老实说,除了可能是 server/client 侧渲染的问题外,我真的不知道还有什么问题。
所以我想问题是:您可以在 sveltekit 项目中导入 winston 吗?如果可以,如何导入? 这个具体问题有什么解决方法吗?
你现在can't use Winston in the browser,尽管目前在路线图上支持它。