ci-info module throw error for "process is not defined"
See original GitHub issueVersion
Reproduction link
https://codepen.io/timyaodpc/pen/bMyazm
Steps to reproduce
Use it in Nuxt/plugins/myplugin.js.
It all works but in browser console it give me a error says "process is not defined"
. Error points to "ci-info"
module first line which tries to use process.env
.
I can see ci-info is a dependency of consola as below:
└─┬ consola@1.3.0 └─┬ std-env@1.3.0 └─┬ is-ci@1.1.0 └── ci-info@1.1.3
I now have to add isServer
condition on const consola = require('consola')
. Otherwise it breaks the client side.
What is expected ?
Browser should no error in console.
What is actually happening?
A error from ci-info
says “process is not defined”.
index.js:3 Uncaught ReferenceError: process is not defined at Object…/node_modules/ci-info/index.js (index.js:3) at webpack_require (bootstrap 20212f6dd5b287d60bc9:712) at fn (bootstrap 20212f6dd5b287d60bc9:117) at Object…/node_modules/is-ci/index.js (index.js:3) at webpack_require (bootstrap 20212f6dd5b287d60bc9:712) at fn (bootstrap 20212f6dd5b287d60bc9:117) at Object.<anonymous> (index.js:1) at Object…/node_modules/std-env/index.js (index.js:18) at webpack_require (bootstrap 20212f6dd5b287d60bc9:712) at fn (bootstrap 20212f6dd5b287d60bc9:117)
Additional comments?
Is Consola
can only be used in server side js?
The consola code index.js first line imported std-env
which can only used in server side.
https://github.com/nuxt/consola/blob/master/src/index.js#L1
Not sure which is the best way to use it in Nuxt and maybe it’s a bug?
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Top GitHub Comments
❤️
Official browser support has arrived with v2.0.0. It only takes 1.5KB / Gzipped for the browser.