Schniz / fnm

🚀 Fast and simple Node.js version manager, built in Rust
https://fnm.vercel.app
GNU General Public License v3.0
18.47k stars 475 forks source link

`tsc --noEmit` hangs indefinitely with `fnm` #1247

Open rxtsel opened 2 months ago

rxtsel commented 2 months ago

I'm experiencing an issue where running the command tsc --noEmit hangs indefinitely and never completes. This issue occurs when using fnm version 1.37.1 with Node.js version 20.0.0.

Here's what I've tried:

The log output from --traceResolution shows the following (last few lines):

======== Module name '@typescript/lib-esnext/collection' was not resolved. ========
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-esnext/array' from '/home/rxtsel/Projects/sound-advice-app/__lib_node_modules_lookup_lib.esnext.array.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Scoped package detected, looking in 'typescript__lib-esnext/array'
Directory '/home/rxtsel/Projects/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/array'
Directory '/home/rxtsel/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/array'
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/array'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/array'
Loading module '@typescript/lib-esnext/array' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/home/rxtsel/Projects/node_modules' does not exist, skipping all lookups in it.
Directory '/home/rxtsel/node_modules' does not exist, skipping all lookups in it.
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-esnext/array' was not resolved. ========
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-esnext/regexp' from '/home/rxtsel/Projects/sound-advice-app/__lib_node_modules_lookup_lib.esnext.regexp.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Scoped package detected, looking in 'typescript__lib-esnext/regexp'
Directory '/home/rxtsel/Projects/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/regexp'
Directory '/home/rxtsel/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/regexp'
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/regexp'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/regexp'
Loading module '@typescript/lib-esnext/regexp' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/home/rxtsel/Projects/node_modules' does not exist, skipping all lookups in it.
Directory '/home/rxtsel/node_modules' does not exist, skipping all lookups in it.
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-esnext/regexp' was not resolved. ========
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/package.json' exists according to earlier cached lookups.
======== Resolving module '@typescript/lib-esnext/string' from '/home/rxtsel/Projects/sound-advice-app/__lib_node_modules_lookup_lib.esnext.string.d.ts__.ts'. ========
Explicitly specified module resolution kind: 'Node10'.
Loading module '@typescript/lib-esnext/string' from 'node_modules' folder, target file types: TypeScript, Declaration.
Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.
Scoped package detected, looking in 'typescript__lib-esnext/string'
Directory '/home/rxtsel/Projects/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/string'
Directory '/home/rxtsel/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/string'
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/string'
Directory '/node_modules' does not exist, skipping all lookups in it.
Scoped package detected, looking in 'typescript__lib-esnext/string'
Loading module '@typescript/lib-esnext/string' from 'node_modules' folder, target file types: JavaScript.
Searching all ancestor node_modules directories for fallback extensions: JavaScript.
Directory '/home/rxtsel/Projects/node_modules' does not exist, skipping all lookups in it.
Directory '/home/rxtsel/node_modules' does not exist, skipping all lookups in it.
Directory '/home/node_modules' does not exist, skipping all lookups in it.
Directory '/node_modules' does not exist, skipping all lookups in it.
======== Module name '@typescript/lib-esnext/string' was not resolved. ========
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/lib/package.json' does not exist according to earlier cached lookups.
File '/home/rxtsel/.local/share/fnm/node-versions/v20.0.0/installation/lib/node_modules/typescript/package.json' exists according to earlier cached lookups.

Environment:

export ZSH="$HOME/.oh-my-zsh"
export EDITOR="nvim"
ZSH_THEME="robbyrussell"

plugins=(
  sudo
    git
    zsh-syntax-highlighting
    zsh-autosuggestions
)

source $ZSH/oh-my-zsh.sh

# Vim Keybindings
# bindkey -v

alias dot="cd ~/dot"
alias pro="cd ~/Projects"
alias zr="source ~/.zshrc"
alias v="nvim"
alias vim="nvim"
alias zz="cd ~/.config"
alias vcfg="cd ~/.config/nvim/ && nvim init.lua"
alias clean="sudo pacman -Rns \$(pacman -Qtdq) && sudo pacman -Sc && yay -Yc && sudo rm -rf ~/.cache/ || true && find ~/.cache -type f -print -delete || true && rm -rf ~/.local/share/Trash || true"
alias z="zellij"

# zed
export PATH=$PATH:~/.local/bin

# fnm
FNM_PATH="/home/rxtsel/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
  export PATH="/home/rxtsel/.local/share/fnm:$PATH"
  eval "`fnm env`"
  eval "$(fnm env --use-on-cd --shell zsh)"
fi

Steps to Reproduce:

  1. Install fnm version 1.37.1.
  2. Use fnm to manage Node.js version 20.0.0.
  3. Run tsc --noEmit in a project directory.

Expected Behavior: tsc --noEmit should complete successfully and exit normally.

Actual Behavior: The command hangs indefinitely and never completes.

Additional Information:

Project tsconfig.ts:

{
    "compilerOptions": {
        "target": "es5",
        "noErrorTruncation": true,
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "strict": true,
        "noEmit": true,
        "esModuleInterop": true,
        "module": "NodeNext",
        "moduleResolution": "NodeNext",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "jsx": "preserve",
        "incremental": true,
        "plugins": [
            {
                "name": "next"
            }
        ],
        "paths": {
            "@/*": ["./src/*"]
        }
    },
    "include": [
        "next-env.d.ts",
        "**/*.ts",
        "**/*.tsx",
        ".next/types/**/*.ts",
        "tailwind.config.js"
    ],
    "exclude": ["node_modules"]
}
chrisvalentine commented 1 month ago

I have this same issue with a nextjs app that uses prisma. if i delete the .prisma/client folder it will complete. Stil trying to figure out what is in that folder but guessing something with the prisma types is messing it up.

Update: The prisma relation seems to have been a false flag.

The error comes from in this

{...register('tag_type_id')}

something in that from react-hook-form will freeze all of typescript if, if I @ts-nocheck the page containing it all is back to expected.