收藏
回答

真机调试一直报错 no such file or directory, access ?

本地测试没有问题,真机调试一直报错

VM61:241

error occurs:ENOENT: no such file or directory, access '/storage/emulated/0/Android/data/com.tencent.mm/MicroMsg/wxanewfiles/7aa4b87a5745cb4ba620783bdc762db2/miniprogramLog/log2'

本地测试可以写入数据到数据库,真机调试报错,且不能将数据写入数据库

回答关注问题邀请回答
收藏

25 个回答

  • 喔wow喔
    喔wow喔
    2022-09-17

    把真机调2.0改成1.0就可以了

    2022-09-17
    有用 8
    回复 7
    • 苏叔
      苏叔
      2023-02-12
      真的有用!感谢大佬!
      2023-02-12
      回复
    • Free.安
      Free.安
      2023-03-07
      解决了:可能是mqtt版本的问题
      在Visual里面将旧版本的mqtt卸载,下载4.1.0的版本就可以用了
      具体操作:先输入:npm uninstall mqtt
      然后npm install mqtt@4.1.0 --save
      2023-03-07
      回复
    • 江湖隐者
      江湖隐者
      2023-07-10
      胡说八道
      2023-07-10
      1
      回复
    • 会计小名
      会计小名
      2024-01-22
      我改成1.0以后有关用户输入的地方接收不到数据了,但是我在本地,预览都可以正常使用,在自动真机调试2.0版本下,也可以正常接收,就1.0不行,您知道是什么原因吗
      2024-01-22
      回复
    • 👀
      👀
      2024-05-26
      你好,我换成1.0后的确不报错了,但是该显示的组件除了导航栏都不见了,请问有方法解决吗?
      2024-05-26
      回复
    查看更多(2)
  • xdh
    xdh
    2022-04-12

    手机上没有这个路径..没有路径也不会自己生成??太弱智了吧?


    2022-04-12
    有用 4
    回复 2
    • Agoni
      Agoni
      2022-09-22
      你他妈才弱智
      2022-09-22
      10
      回复
    • 啄啄~
      啄啄~
      2022-12-20回复Agoni
      很久没有来这了  早就解决了  好像是重启就好了  时间太久了 我也有点忘了
      2022-12-20
      回复
  • 活在梦里
    活在梦里
    2023-03-31

    2023了

    2023-03-31
    有用 2
    回复 7
    查看更多(2)
  • ABCD
    ABCD
    2024-08-14

    请问这个问题解决了吗?2024/8/14

    2024-08-14
    有用 1
    回复 1
    • 大大tt
      大大tt
      2024-08-27
      全网都找不到,想去手动创建文件夹但是不知道路径
      2024-08-27
      回复
  • 花架上的绳索
    花架上的绳索
    2022-05-31

    查看了一下,报这个错是因为手机上是没有这个文件的,创建文件log1和log2文件后,就可以避免报错了,小程序会向log1文件中写日,log2暂时没发现是干啥的

    这是小程序平台的错误,但是无法给社区管理员提供必现的代码(或者说无法保证复现的代码在别人的机器上也能复现),所以才没修复吧,我看最早18年就有人提这类问题了。

    但是这小程序平台的开发也太省事了吧,你要写文件,你不检查吗,直接报错?

    2022-05-31
    有用 1
    回复 8
    •  life?!
       life?!
      2022-08-09
      那请问怎么解决呢,在哪里创建log1 和log2呢 谢谢
      2022-08-09
      回复
    • 罗天旭
      罗天旭
      2022-08-17回复 life?!
      请问解决了嘛
      2022-08-17
      回复
    • 啄啄~
      啄啄~
      2022-12-20回复罗天旭
      很久没来这里了  好像是重启电脑了 就没事了
      2022-12-20
      回复
    • ´৺`
      ´৺`
      2023-04-26
      要怎么解决
      2023-04-26
      回复
    • 花架上的绳索
      花架上的绳索
      2023-08-10
      没有解决,但是因为不影响我调试,我也不跟了,啥也不说了,开发者都懂
      2023-08-10
      回复
    查看更多(3)
  • 姜小华
    姜小华
    2022-02-13

    解决了吗?

    2022-02-13
    有用 1
    回复 4
    • 刘广阔
      刘广阔
      2022-08-01
      请问解决了吗?
      2022-08-01
      回复
    • 罗天旭
      罗天旭
      2022-08-17回复刘广阔
      请问解决了吗
      2022-08-17
      回复
    • 被狗追过的夏天
      被狗追过的夏天
      2022-09-12回复刘广阔
      同问 解决了吗?我去这个错误太弱智了。他没有创建 文件夹权限吗
      2022-09-12
      回复
    • 啄啄~
      啄啄~
      2022-12-20
      解决了 我有点忘了 是怎么解决的了  时间太久了  好像我是重启了电脑 就没事了
      2022-12-20
      回复
  • Mr.Zhao
    Mr.Zhao
    2021-09-30

    这个报错跟你数据库没关系,而且我不知道你说的数据库具体是啥,用的真机调试2.0吧,用1.0

    2021-09-30
    有用 1
    回复 1
    • lijin
      lijin
      2021-11-01
      用1.0自定义tabBar会报错
      2021-11-01
      回复
  • 乐图
    乐图
    03-19
      onLaunch: function (options) {
          // ......
    
          const fs = wx.getFileSystemManager();
          const logDirPath = `${wx.env.USER_DATA_PATH}/miniprogramLog`;
          const logFiles = ['log1', 'log2', 'log3', 'log4'];
    
          // 创建目录
          fs.access({
              path: logDirPath,
              success: () => {
                  console.log('Directory exists');
                  this.checkAndCreateFiles(fs, logDirPath, logFiles);
              },
              fail: () => {
                  console.log('Directory does not exist, creating it');
                  fs.mkdir({
                      dirPath: logDirPath,
                      success: () => {
                          console.log('Directory created successfully');
                          // 正确传递参数
                          this.checkAndCreateFiles(logDirPath, logFiles); 
                      },
                      fail: err => {
                          console.error('Failed to create directory', err);
                      }
                  });
              }
          })
      },
      //.......
    
    03-19
    有用
    回复
  • 乐图
    乐图
    03-19
      onLaunch: function (options) {
          // ......
    
          const fs = wx.getFileSystemManager();
          const logDirPath = `${wx.env.USER_DATA_PATH}/miniprogramLog`;
          const logFiles = ['log1', 'log2', 'log3', 'log4'];
    
          // 创建目录
          fs.access({
              path: logDirPath,
              success: () => {
                  console.log('Directory exists');
                  this.checkAndCreateFiles(fs, logDirPath, logFiles);
              },
              fail: () => {
                  console.log('Directory does not exist, creating it');
                  fs.mkdir({
                      dirPath: logDirPath,
                      success: () => {
                          console.log('Directory created successfully');
                          // 正确传递参数
                          this.checkAndCreateFiles(logDirPath, logFiles); 
                      },
                      fail: err => {
                          console.error('Failed to create directory', err);
                      }
                  });
              }
          })
      },
    
      checkAndCreateFiles: function(fs, logDirPath, logFiles) {
          logFiles.forEach(logFile => {
              const logFilePath = `${logDirPath}/${logFile}`;
              fs.access({
                  path: logFilePath,
                  success: () => {
                      console.log(`${logFile} exists`);
                  },
                  fail: () => {
                      console.log(`${logFile} does not exist, creating it`);
                      fs.writeFile({
                          filePath: logFilePath,
                          data: '',
                          success: res => {
                              console.log(`${logFile} created successfully`);
                          },
                          fail: err => {
                              console.error(`Failed to create ${logFile}`, err);
                          }
                      });
                  }
              });
          });
      },
      //.......
    
    03-19
    有用
    回复
  • 乐图
    乐图
    03-19
      onLaunch: function (options) {
          this.checkLoginStatus();
    
    
          const fs = wx.getFileSystemManager();
          const logDirPath = `${wx.env.USER_DATA_PATH}/miniprogramLog`;
          const logFiles = ['log1', 'log2', 'log3', 'log4'];
    
    
          // 创建目录
          fs.access({
              path: logDirPath,
              success: () => {
                  console.log('Directory exists');
                  this.checkAndCreateFiles(fs, logDirPath, logFiles);
              },
              fail: () => {
                  console.log('Directory does not exist, creating it');
                  fs.mkdir({
                      dirPath: logDirPath,
                      success: () => {
                          console.log('Directory created successfully');
                          // 正确传递参数
                          this.checkAndCreateFiles(logDirPath, logFiles); 
                      },
                      fail: err => {
                          console.error('Failed to create directory', err);
                      }
                  });
              }
          })
      },
    
    
      checkAndCreateFiles: function(fs, logDirPath, logFiles) {
          logFiles.forEach(logFile => {
              const logFilePath = `${logDirPath}/${logFile}`;
              fs.access({
                  path: logFilePath,
                  success: () => {
                      console.log(`${logFile} exists`);
                  },
                  fail: () => {
                      console.log(`${logFile} does not exist, creating it`);
                      fs.writeFile({
                          filePath: logFilePath,
                          data: '',
                          success: res => {
                              console.log(`${logFile} created successfully`);
                          },
                          fail: err => {
                              console.error(`Failed to create ${logFile}`, err);
                          }
                      });
                  }
              });
          });
      },
    
    app.js
    
    03-19
    有用
    回复

正在加载...

登录 后发表内容