ionic-team / vscode-ionic

Visual Studio Code Ionic Extension
Other
11 stars 1 forks source link

Npm errors in output #180

Closed Mankore closed 2 months ago

Mankore commented 3 months ago

On startup in ionic output window i see following errors:

npm list --json [error] SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) npm outdated --json [error] TypeError: items is not iterable

have several projects, one of which is in NX monorepo, same error everywhere. Other extensions work fine with npm and node. Do you have any ideas what could be the issue? Thanks!

dtarnawsky commented 3 months ago

The command npm list --json should return valid json. You could reply with the result of this command so I could understand if it is just npm returning malformed json or if there is another problem (like inability to find npm).

Johannnnes commented 3 months ago

I have the same errors..

`

npm list --json [error] SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2) npm outdated --json [error] TypeError: items is not iterable `

Johannnnes commented 3 months ago

@dtarnawsky The result of that command = [error] SyntaxError: Expected property name or '}' in JSON at position 1 (line 1 column 2)

Mankore commented 3 months ago

@dtarnawsky npm list --json returns valid json in regular terminal, but in ionic output window it shows those errors

dtarnawsky commented 3 months ago

To reproduce the error I would need a copy of your project. Are you able to share your code to damian@ionic.io?

Mankore commented 3 months ago

This error is not project-dependent, it also happens for me in cloned ionic-react-conference-app for example.

dtarnawsky commented 3 months ago

The extension is either not finding npm or is finding a version of npm that is very outdated. This can be caused by a non standard shell and you can specify the shell you use in Advanced > Settings > Shell Path. You could also have problems if you are using a misconfigured node manager like nvm or volta. I've also seen problems where VS Code is so old it cannot install the latest version of the extension so uses a really old version.

So to get started, what node version are you using? and version of npm? and any node manager used? Are you using Windows, Linux or Mac?

Mankore commented 3 months ago

Mac (2019) node v20.16.0 npm 10.8.1 nvm 0.40.1 VS Code latest

I'm using zsh on system level as a default terminal, and bash in vscode. This might be the problem i guess, will try to play around it

P.S. setting default terminal to zsh for vscode and ionic extension didn't help.

dtarnawsky commented 2 months ago

Hi @Mankore , there was a small change to how .nvm is handled in v1.93 of the extension. I was wondering if this resolved your issue?

Mankore commented 2 months ago

Hi @dtarnawsky, yes the errors are gone now, thanks :) Closing the issue