ionic-team / vscode-ionic

Visual Studio Code Ionic Extension
Other
5 stars 0 forks source link

yarn commands not working #137

Closed robsonos closed 1 month ago

robsonos commented 2 months ago

Here is the output from the extension:

> yarn info --json
[error] TypeError: Cannot read properties of undefined (reading 'lastIndexOf')
> yarn outdated --format=json
[error] SyntaxError: Unexpected token 'y', "yarn outda"... is not valid JSON

I am using v1.85.1

dtarnawsky commented 2 months ago

Hey @robsonos , do you have yarn installed and what version are you using? Also, if you run yarn info --json does it work on your terminal? Also, if you try yarn outdated --format=json does it work?

robsonos commented 2 months ago

Hi @dtarnawsky,

I just upgraded to Ionic extension v1.85.2 and the problem persists. Here are some more details about my environment:

Digging a bit more into the issue I found: yarn info --json from VSCode's and native terminal returns:

{"type":"error","data":"Received invalid response from npm."}

npm info returns:

npm  info
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/MY-REPO - Not found
npm ERR! 404 
npm ERR! 404  'MY-REPO@*' is not in this registry.
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! A complete log of this run can be found in: /Users/MY-USER/.npm/_logs/2024-04-22T01_28_50_450Z-debug-0.log

My understanding for this one is that npm info (an alias for npm view) without any arguments is looking into my repo in npm's registry, which does not exist. Not sure what the intention was with npm info here.

yarn outdated --format=json from VSCode's and native terminal returns:

yarn outdated v1.22.22
info Color legend : 
 "<red>"    : Major Update backward-incompatible updates 
 "<yellow>" : Minor Update backward-compatible features 
 "<green>"  : Patch Update backward-compatible bug fixes
Package Current Wanted Latest Package Type    URL               
eslint  8.57.0  8.57.0 9.1.0  devDependencies https://eslint.org
✨  Done in 7.62s.

That is not outputting a JSON as you guys may have intended. Perhaps you guys meant to use yarn outdated --json?

Cheers.

dtarnawsky commented 2 months ago

Hey @robsonos , could you try this out for me: in your package.json add the line: "packageManager": "yarn@1.0.0"

This should change the command yarn outdated --format=json (which is used with > v1 yarn) to yarn outdated --json.

I'm not sure where you have MY-REPO in your package.json but you'll need to remove that in order to get yarn info --json to work.

Also, as a generate note, it is probably worth moving away from Yarn v1.

robsonos commented 2 months ago

Hi @dtarnawsky,

The two previously mentioned errors are gone after adding "packageManager": "yarn@1.0.0" to package.json. However, now:

[Ionic] Detected nvm (20) for this project.
> yarn list --json
[error] TypeError: Cannot read properties of undefined (reading 'lastIndexOf')

That one does seem to output properly from the terminal:

% yarn list --json
{"type":"activityStart","data":{"id":0}}
{"type":"activityTick","data":{"id":0,"name":"@angular/animations@^17.0.0"}}
{"type":"activityTick","data":{"id":0,"name":"tslib@^2.3.0"}}
{"type":"activityTick","data":{"id":0,"name":"@angular/common@
...

I used MY-REPO instead of the real name for privacy reasons. Sorry for the confusion. Also, thanks for the tip regarding Yarn v1.

Cheers

dtarnawsky commented 1 month ago

Hi @robsonos , this issue should now be resolved.