node 10.0.0 有个改变, Using non-string values for process.env is deprecated 这个是什么 意思呢
发布于 6 年前 作者 zhangshiqiu 2662 次浏览 来自 问答

nodejs.jpg

3 回复

后面不是有一个链接么,点过去看 DIFF 就知道了,里面还有对应的 fixture 看。

Assigning a property on `process.env` will implicitly convert the value to a string to a string. **This behavior is deprecated.** 
Future versions of Node.js may throw an error when the value is not a string, number, or boolean.

简单的说,env 的赋值只能是 string, number 和 boolean,之前的行为是会自动转换为 string,现在是会打个 warning。

楼上说的挺清楚了,这里补充一下,一般往 process.env 上赋值的情况都是要给 worker 进程传递信息。这里加了警告可以帮助发现直接一个 Object 赋值上去强转成了 ‘[object Object]’ 一样没有意义的字符串。

回到顶部