zx icon indicating copy to clipboard operation
zx copied to clipboard

zx --install do not install dependencies

Open pawelmidur opened this issue 1 year ago • 7 comments

Expected Behavior

It should install all the dependencies that are included in the file, version 7.2.0 has no problem but version 7.2.2 installs nothing and show error

Actual Behavior

$ node -v
v16.20.0
$ npm i zx --location=global
added 56 packages, and audited 57 packages in 5s
10 packages are looking for funding
$ zx -v
7.2.2
$ zx --install ./.deploy/deployer.mjs -e front
Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'node-ssh' imported from /builds/......ployer.mjs
    at new NodeError (node:internal/errors:387:5)
    at packageResolve (node:internal/modules/esm/resolve:852:9)
    at moduleResolve (node:internal/modules/esm/resolve:901:20)
    at defaultResolve (node:internal/modules/esm/resolve:1115:11)
    at nextResolve (node:internal/modules/esm/loader:163:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:[75](https://gitlab.com/........139#L75):36) {
  code: 'ERR_MODULE_NOT_FOUND'
}

Version 7.2.0 has no such problems and the whole script works fine, I have not checked version 7.2.1 but it seems to me that it works, because the problems started to occur 4 days ago

Specifications

  • Version: 7.2.2
  • Platform: node v16.20.0

pawelmidur avatar May 05 '23 10:05 pawelmidur

@pawelmidur Is this assigned to someone. If not i would like to work on this issue !

ronitsharma03 avatar May 07 '23 13:05 ronitsharma03

@pawelmidur Is this assigned to someone. If not i would like to work on this issue !

no one is assigned, so go ahead 👍

pawelmidur avatar May 07 '23 13:05 pawelmidur

@pawelmidur thanks a lot!

ronitsharma03 avatar May 07 '23 14:05 ronitsharma03

@ronitsharma03 I checked and it only occurs when the files are import:

script.mjs

#!/usr/bin/env zx

import 'zx/globals';

import { dep } from './dep.mjs';

dep();
await $`echo START!`;

dep.mjs

import chalk from 'chalk';

export const dep = async () => {
  console.log(chalk.greenBright('Test dependencies on other file'));
};

and run zx --install ./script.mjs

I don't know if this is the correct use flag --install, but it works on version 7.2.1

pawelmidur avatar May 07 '23 15:05 pawelmidur

@pawelmidur In this command zx --install ./.deploy/deployer.mjs -e front it is looking for deployer.mjs file in .deploy directory but it is missing. Maybe it's got deleted accidentally! Can you check please?

ronitsharma03 avatar May 07 '23 16:05 ronitsharma03

@pawelmidur In this command zx --install ./.deploy/deployer.mjs -e front it is looking for deployer.mjs file in .deploy directory but it is missing. Maybe it's got deleted accidentally! Can you check please?

I don't think it's a problem with any package inside ZX, I just think it's a problem with parsing dependencies and pasting them into the command line that need to be installed when using the --install flag

so install node-ssh inside ZX will not help

pawelmidur avatar May 08 '23 09:05 pawelmidur

Seems the @dev version works. npm i -g zx@dev

jianwu avatar Nov 08 '23 07:11 jianwu