Voxelum / minecraft-launcher-core-node

Provide packages to install Minecraft, launch Minecraft and more to build launcher with NodeJs/Electron!
https://docs.xmcl.app/en/core/
MIT License
174 stars 25 forks source link

Error on running install: minecraft/java (core._mkdir is not a function) #265

Closed Gagafeee closed 1 year ago

Gagafeee commented 1 year ago

Hi I posted a question on discord recently, but after no response i think this is a bug, https://discord.com/channels/405213567118213121/994138621101740093/1109817202586177556,

I run on electron-react app with:

and when I try to install something, it returns strange errors:

On installing Java:

const dir = path.join(app.getPath('userData'), 'Local Java\\');
const tempDownloadDir = path.join(app.getPath('userData'), 'Download Cache\\');
//create dir if not exist
if (!fs.existsSync(dir)) fs.mkdirSync(dir);
if (!fs.existsSync(tempDownloadDir)) fs.mkdirSync(tempDownloadDir);

installJreFromMojang({
  destination: dir,
  unpackLZMA: require('lzma-native').LZMA(),
  cacheDir: tempDownloadDir
});

and it returns:

TypeError: core._pipeline is not a function
at ~~\@xmcl\http\download.ts:191:23
at processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Promise.all (index 0)
at async Download.processDownload (~~\@xmcl\http\download.ts:151:9)
at async Download.downloadUrl (~~\@xmcl\http\download.ts:236:17)
at async Download.start (~~\@xmcl\http\download.ts:290:21)
at async DownloadJRETask.runTask (~~\@xmcl\task\index.ts:269:24)

On installing Minecraft files:

same as here, I run install();

const dir = path.join(app.getPath('userData'), 'Game Instance\\');
const versionList = await getVersionList();
const resolvedVersion = versionList.versions.find((MinecraftVersion, i) => {
    return MinecraftVersion.id === version.id;
  });
install(resolvedVersion, dir, {}).then(res => {
  console.log(res);
  resolve();
}).catch(err => {
  reject({ ...knowGameError.GameFileCannotInstallError, additionalError: err });
});

I get a similar error:

TypeError: core._mkdir is not a function
at ensureDir (~~\@xmcl\utils.ts:26:15)
at ensureFile (~~\@xmcl\utils.ts:65:12)
at Download.start (~~\@xmcl\http\download.ts:271:23)
at InstallJsonTask.process (~~\@xmcl\downloadTask.ts:50:28)
at InstallJsonTask.runTask (~~\@xmcl\task\index.ts:269:35)
at processTicksAndRejections (node:internal/process/task_queues:95:5)

It seems missing a lib or something, Especially since there is no function core._mkdir or core.pipeline.

Thanks in advance for help !

Gagafeee commented 1 year ago

I re-install @xmcl/core and @xmcl/installer with --save-dev and it works !