我想在节点js中读取一个文本文件
这是我的代码:
const fs = require('fs');
const contents = fs.readFileSync('1.txt', 'utf8');
console.log(contents);
但我收到了这个错误:
(node:5168) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Octal escape sequences are not allowed in strict mode.
(node:5168) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
此时,如何阅读文本文件?
答案 0 :(得分:0)
该计划运作良好 问题在于我写得不好的文件的名称