Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miniprogramRoot 不是为空,所以miniprogram-ci会报错 #15947

Open
wuweikd opened this issue Jun 20, 2024 · 1 comment
Open

miniprogramRoot 不是为空,所以miniprogram-ci会报错 #15947

wuweikd opened this issue Jun 20, 2024 · 1 comment

Comments

@wuweikd
Copy link

wuweikd commented Jun 20, 2024

相关平台

微信小程序

小程序基础库: [system] WeChatLib: 3.4.3 (2024.5.17 14:14:37)
使用框架: React

复现步骤

使用build:weapp 后,生成的dist/project.config.json 的 "miniprogramRoot"是 "./"

如果将dist目录导入小程序 ,小程序会强制修改为 "miniprogramRoot": ""。

如果是上述逻辑,也没什么问题,问题是,使用build:weapp后,再使用小程序提供的miniprogram-ci进行上传。那么小程序会报文件找不到的错误。

CodeError: Error: {"errCode":-1,"errMsg":"inner upload fail with errcode: 800059, errmsg: error: iconPath=assets/imgs/shengdanqiu.png, file not found"}

我也有个临时解决办法,就是通过node fs,强制将miniprogramRoot设置为“”,但是属于骚操作了。

const changeFileMiniprogramRoot = () => {
  const configPath = path.join(__dirname, "../dist/project.config.json");

  // 读取 dist/project.config.json 文件内容
  fs.readFile(configPath, "utf8", (err, data) => {
    if (err) {
      console.error("Error reading file:", err);
      return;
    }

    // 解析 JSON 数据
    const config = JSON.parse(data);

    // 修改数据 有点骚操作
    config.miniprogramRoot = "";

    // 将修改后的数据转换为 JSON 字符串
    const updatedConfig = JSON.stringify(config, null, 2);

    // 将修改后的数据写回文件
    fs.writeFile(configPath, updatedConfig, "utf8", (err) => {
      if (err) {
        console.error("Error writing file:", err);
        return;
      }
      console.log("File updated successfully.");
    });
  });
};

期望结果

生成的dist/project.config.json 的 "miniprogramRoot"是 ""

实际结果

生成的dist/project.config.json 的 "miniprogramRoot"是 "./"

环境信息

👽 Taro v3.6.29


  Taro CLI 3.6.29 environment info:
    System:
      OS: Windows 10 10.0.19045
    Binaries:
      Node: 18.20.2 - C:\Program Files\nodejs\node.EXE
      Yarn: 1.22.22 - ~\AppData\Roaming\npm\node_modules\yarn\bin\yarn.CMD
      npm: 10.5.2 - C:\Program Files\nodejs\npm.CMD
    npmPackages:
      @tarojs/cli: 3.6.29 => 3.6.29
      @tarojs/components: 3.6.29 => 3.6.29
      @tarojs/helper: 3.6.29 => 3.6.29
      @tarojs/plugin-framework-react: 3.6.29 => 3.6.29
      @tarojs/plugin-platform-alipay: 3.6.29 => 3.6.29
      @tarojs/plugin-platform-h5: 3.6.29 => 3.6.29
      @tarojs/plugin-platform-jd: 3.6.29 => 3.6.29
      @tarojs/plugin-platform-qq: 3.6.29 => 3.6.29
      @tarojs/plugin-platform-tt: 3.6.29 => 3.6.29
      @tarojs/plugin-platform-weapp: 3.6.29 => 3.6.29
      @tarojs/react: 3.6.29 => 3.6.29
      @tarojs/rn-runner: 3.6.29 => 3.6.29
      @tarojs/rn-supporter: 3.6.29 => 3.6.29
      @tarojs/router-rn: 3.6.30 => 3.6.30
      @tarojs/runtime: 3.6.29 => 3.6.29
      @tarojs/runtime-rn: 3.6.29 => 3.6.29
      @tarojs/shared: 3.6.29 => 3.6.29
      @tarojs/taro: 3.6.29 => 3.6.29
      @tarojs/taro-loader: 3.6.29 => 3.6.29
      @tarojs/taro-rn: 3.6.29 => 3.6.29
      @tarojs/webpack5-runner: 3.6.29 => 3.6.29
      babel-preset-taro: 3.6.29 => 3.6.29
      eslint-config-taro: 3.6.29 => 3.6.29
      expo: ~47.0.3 => 47.0.14
      react: ^18.1.0 => 18.3.1
      react-native: ^0.70.1 => 0.70.15


@wuweikd
Copy link
Author

wuweikd commented Jun 21, 2024

原因是,miniprogram-ci 2.0.0 版本就不行了,降级为1.9.16版本可以。

This was referenced Jun 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant