dojo / cli

:rocket: Dojo - command line tooling.
http://dojo.io
Other
25 stars 34 forks source link

Running older versions of npm with execa prevents retriving installable commands as JSON #251

Closed JamesLMilner closed 6 years ago

JamesLMilner commented 6 years ago

Bug

When using older versions of npm such as 3.5.2 (this is what you get when you install nodejs with Ubuntu by default), execa will fail to get the JSON response as intended when passing in the search command with necessary arguments.

screenshot_20180815_115024

From reasoning this seems to be because the --json argument is being ignored which causes it to fail.

Code

Try:

const execa = require("execa");

async function test() {
    console.log( 
        await execa('npm', ['search', '@dojo', 'cli-', '--json',  '--searchstaleness=0'])
    );
}

test();

Using a older version of NPM.

Expected behavior:

JSON response that doesn't throw an error in the dojo cli search function.

Actual behavior:

Invalid response from npm search

JamesLMilner commented 6 years ago

Looks like Ubuntu 18.04 might be shipping npm version 3.5.2: https://askubuntu.com/questions/1036278/npm-is-incorrect-version-on-latest-ubuntu-18-04-installation

The package list: https://packages.ubuntu.com/xenial/web/npm