Closed neochne closed 1 month ago
The error "TypeError: Assignment to constant variable" in the fanyi
package is caused by attempting to reassign a value to a constant variable, specifically with the chalk
module in the iciba
function. To fix this, you should change the declaration of chalk
from const
to let
in the lib/print.js
file of the fanyi
package:
let chalk = require('chalk');
This adjustment allows chalk
to be reassigned later in the code without causing an error. You'll need to make this change directly in the source code of the fanyi
package on your local machine.
To continue the conversation, mention @dosu.
⠹ node:events:491 throw er; // Unhandled 'error' event ^
TypeError: Assignment to constant variable. at exports.iciba (/usr/local/lib/node_modules/fanyi/lib/print.js:10:11) at /usr/local/lib/node_modules/fanyi/index.js:48:17 at Parser. (/usr/local/lib/node_modules/fanyi/node_modules/xml2js/lib/parser.js:304:18)
at Parser.emit (node:events:513:28)
at SAXParser.onclosetag (/usr/local/lib/node_modules/fanyi/node_modules/xml2js/lib/parser.js:262:26)
at emit (/usr/local/lib/node_modules/fanyi/node_modules/sax/lib/sax.js:625:35)
at emitNode (/usr/local/lib/node_modules/fanyi/node_modules/sax/lib/sax.js:630:5)
at closeTag (/usr/local/lib/node_modules/fanyi/node_modules/sax/lib/sax.js:890:7)
at SAXParser.write (/usr/local/lib/node_modules/fanyi/node_modules/sax/lib/sax.js:1437:13)
at exports.Parser.Parser.parseString (/usr/local/lib/node_modules/fanyi/node_modules/xml2js/lib/parser.js:323:31)
Emitted 'error' event on Parser instance at:
at exports.Parser.Parser.parseString (/usr/local/lib/node_modules/fanyi/node_modules/xml2js/lib/parser.js:327:16)
at Parser.parseString (/usr/local/lib/node_modules/fanyi/node_modules/xml2js/lib/parser.js:5:59)
at exports.parseString (/usr/local/lib/node_modules/fanyi/node_modules/xml2js/lib/parser.js:369:19)
at /usr/local/lib/node_modules/fanyi/index.js:44:9
at done (/usr/local/lib/node_modules/fanyi/node_modules/needle/lib/needle.js:474:14)
at PassThrough. (/usr/local/lib/node_modules/fanyi/node_modules/needle/lib/needle.js:734:9)
at PassThrough.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1359:12)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
Node.js v18.12.1