0

I have a vite/vue/typescript project. VSCode is telling me to upgrade Typescript because of a bug. I've been trying to do that, but it's not working, and seems to have revealed a problem in my pnpm setup or configuration on linux:

$ pnpm -g up typescript@latest
 ERROR  Unable to find the global bin directory
Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.
$ pnpm setup
Appended new lines to /home/jrefior/.bashrc
Next configuration changes were made:
export PNPM_HOME="/home/jrefior/.local/share/pnpm"
export PATH="$PNPM_HOME:$PATH"
To start using pnpm, run:
source /home/jrefior/.bashrc
$ source ~/.bashrc
$ pnpm -g up typescript@latest
 ERR_PNPM_NO_PKG_MANIFEST  No package.json found in /home/jrefior/.local/share/pnpm/global/5

and trying again later:

~ $ pnpm config set global-dir /home/jrefior/.local/share/pnpm
~ $ pnpm -g up typescript@latest
 ERR_PNPM_NO_PKG_MANIFEST  No package.json found in /home/jrefior/.local/share/pnpm/5
~ $ pnpm setup
No changes to the environment were made. Everything is already up to date.
~ $ pnpm -g up typescript@latest
 ERR_PNPM_NO_PKG_MANIFEST  No package.json found in /home/jrefior/.local/share/pnpm/5
~ $ pnpm -g setup
 ERROR   ERROR  Unknown option: 'global'

How do I set up pnpm to allow me to upgrade typescript?

For context:

~ $ pnpm version
{
  npm: '8.19.2',
  node: '18.12.1',
  v8: '10.2.154.15-node.12',
  uv: '1.44.2',
  zlib: '1.2.12',
  brotli: '1.0.9',
  ares: '1.18.1',
  modules: '108',
  nghttp2: '1.47.0',
  napi: '8',
  llhttp: '6.0.10',
  openssl: '3.0.5',
  cldr: '41.0',
  icu: '71.1',
  tz: '2022a',
  unicode: '14.0'
}
~ $ pnpm --version
7.17.0
~ $ cat /etc/fedora-release
Fedora release 37 (Thirty Seven)
~ $ uname -r
6.1.7-200.fc37.x86_64

Update: I kept working on this and tried to resolve with a sudo npm command:

$ sudo npm install -g typescript@latest
$ tsc --version
Version 5.0.4

That appeared to succeed, but when I opened vscode in my project it still said I was using a bad typescript version and I should upgrade to 5.0+.

Then I remembered I recently disabled the startup nag to update vscode at new releases. A little more research and I found TypeScript is packaged with vscode. Or at least it used to be, current docs say it's not. So for my version of vscode, now I had one version in my editor, and another in the rest of my environment. Doesn't this mean that my build would use a different version than my editor? Seems problematic. But upgrading vscode did align the Typescript version in my editor with the one in the rest of my environment and stop vscode from complaining about TS version:

sudo dnf upgrade code
jrefior
  • 4,092
  • 1
  • 19
  • 29

0 Answers0