node.js系列-常见问题处理方案(持续更新)

问题1:nodejs 如何使用 atob、btoa 解决方案(base64与uint8array转换),btoa和atob在nodejs中应该怎么写?

``

浏览器中我们可以这样使用:

复制代码
btoa('123456')
'MTIzNDU2'
atob('MTIzNDU2')
'123456'

node.js中实现方案

复制代码
const btoaText = Buffer.from("123456").toString("base64");
console.log(btoaText); // MTIzNDU2
const atobText = Buffer.from("MTIzNDU2", "base64").toString("binary");
console.log(atobText); // 123456

问题2:node.js中出现警告:ESLint - 'process' is not defined

解决方案:

修改eslint配置文件 , 举个栗子:.eslintrc.js

复制代码
module.exports = {
    "env": {
        "node": true,
        "es2021": true
    },
    "extends": "eslint:recommended",
    "overrides": [
        {
            "env": {
                "node": true
            },
            "files": [
                ".eslintrc.{js,cjs}"
            ],
            "parserOptions": {
                "sourceType": "script"
            }
        }
    ],
    "parserOptions": {
        "ecmaVersion": "latest",
        "sourceType": "module"
    },
    "rules": {
        
    }
}

问题3:node.js中console.log如何变成彩色log

复制代码
npm install colors

使用方案

复制代码
import colors from "colors";
 console.log(( "2023-08-02:  " + _).bgGreen);

待继续补充

  • 今天就写到这里啦~
  • 小伙伴们,( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ我们明天再见啦~~
  • 大家要天天开心哦

欢迎大家指出文章需要改正之处~

学无止境,合作共赢

欢迎路过的小哥哥小姐姐们提出更好的意见哇~~

相关推荐
小高00720 小时前
Elips-Core:轻量级 Node.js Web 框架核心实现
前端·javascript·node.js
前端流一20 小时前
Node.js 原生实现JSON-RPC及长进程双向通信实践
node.js
undsky1 天前
【RuoYi-Eggjs】:多数据库与 MyBatis 特性详解
node.js·mybatis·egg.js
weixin_462446231 天前
使用 cnchar 生成汉字拼音、笔画、组词数据(Node.js 实战教程)
node.js
想学后端的前端工程师1 天前
【Node.js后端开发实战指南:从入门到企业级应用】
node.js
weixin_462446231 天前
Node.js 纯 JS 生成 SVG 练字纸(米字格 / 田字格)完整实现解析
开发语言·javascript·node.js
cypking1 天前
三、NestJS 开发实战文档-->集成 MySQL(TypeORM)
前端·数据库·mysql·adb·node.js
Misnearch1 天前
npm包-serve包使用
前端·npm·node.js
千寻girling2 天前
计算机组成原理-全通关源码-实验(通关版)---头歌平台
前端·面试·职场和发展·typescript·node.js
damo王2 天前
how to install npm in ubuntu24.04?
前端·npm·node.js