本文介绍: 遇到这个错误,上代码import thenFs fromthen-fsfunction getAllFile() { const r1 = await thenFs.readFile(‘./file/1.txt‘, ‘utf8′) console.log(r1) const r2 = await thenFs.readFile(‘./file/1.txt‘, ‘utf8′) console.log(r2) const r3 = await thenFs.readFi..

遇到这个错误,上代码

import thenFs from 'then-fs'

function getAllFile() {
  const r1 = await thenFs.readFile('./file/1.txt', 'utf8')
  console.log(r1)
  const r2 = await thenFs.readFile('./file/1.txt', 'utf8')
  console.log(r2)
  const r3 = await thenFs.readFile('./file/1.txt', 'utf8')
  console.log(r3)
}

getAllFile()

代码块如上所示,真的找了很久的bug,一直都不明白这个是什么意思,也看到了不少的说是 ESlint问题node.js 默认支持 common.js and so on

但是实际意义上,是我 async没加!对就是这个这么蠢得错法。无语了。

解决办法

async function getAllFile() {…..

男默女泪,真的找了很久。。。

即可

原文地址:https://blog.csdn.net/weixin_48070985/article/details/123604576

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任

如若转载,请注明出处:http://www.7code.cn/show_16539.html

如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱suwngjj01@126.com进行投诉反馈,一经查实,立即删除

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注