Question 1: How does nodejs use atob and btoa solutions (base64 and uint8array conversion), how should btoa and atob be written in nodejs?
``
In the browser we can use this:
btoa('123456')
'MTIzNDU2'
atob('MTIzNDU2')
'123456'
Implementation scheme in 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
Problem 2: A warning appears in node.js: ESLint - 'process' is not defined
solution:
Modify the eslint configuration file, for example: .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": {
}
}
Question 3: How does console.log become a colored log in node.js
npm install colors
usage plan
import colors from "colors";
console.log(( "2023-08-02: " + _).bgGreen);
to be added
- I will write here today~
- Friends, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ See you tomorrow~~
- Everyone be happy every day
Everyone is welcome to point out where the article needs to be corrected~
Learning is endless, cooperation is win-win