I’m trying to run a project locally on my macOS using yarn cross-env NODE_ENV=development nest start --watch
, but the command stays stuck without output or progress.
Environment:
- macOS version: Sonoma 14.6.1
- Node.js version: 20.17.0
- Yarn version: 1.22.22
- Project dependencies: Nest.js, typeorm
These are some actions that I have tried:
- Verified that yarn and node are installed correctly using
yarn --version
andnode --version
- Cleared the
node_modules
and reinstalled dependencies withyarn install
- Tried running
yarn dev
with different versions of Node.js using nvm to switch versions - Checked for any error messages in the console, but none are displayed
- Restarted my machine and ensured no other processes are using the necessary ports
I’m expecting the development server should start successfully and be accessible via the configured port. I’m using Docker for the project. The project works fine on other systems and my team members have no problem in running it
Does anyone have suggestions on troubleshooting steps or what could be causing this issue?
1
This is a corruption in your yarn instance. I have written a similar answer here on how to fix the problem with npm in case none of the solutions here work.
Please note that each solution is listed in the order that I would recommend trying them. However, there shouldn’t be any serious harm in trying them in a different order.
Clear yarn’s cache
From the yarn docs:
Remove the shared cache files.
Local
- Open your terminal/shell environment in the root of your system
- Run
yarn cache clean
Global
- Open your terminal/shell environment in the root of your system
- Run
yarn cache clean --miror
The primary difference between between the two commands is that local will delete the root yarn cache files and global will delete all yarn cache files. I would try local first to not have to build something twice.
Repair Node.js
If the above is not working the problem is likely not yarn but instead Node. At this point the best option is to repair Node.js.
On Windows
- Open the original installer file with file explorer (likely in downloads). What’s important is the file is of type
Windows Installer Package
. - Click
next
in the installer window - Click
repair
- Click
repair
again - Click
finish
On Unix-based system(macOS/Linux based OSs)
Unfortunately on Unix based systems there is no simple repair
button. Repairing Node on these systems is outside the scope of this answer.
In short you should remove all folders owned by Node and npm. See Uninstall Node.JS using Linux command line?
A note before going further
If by this point your problem still hasn’t been fixed there is a bug somewhere in your system or a tool you are using. Below will help you determine what could be at fault.
Upgrading yarn
From the yarn docs:
The preferred way to manage Yarn is by-project and through Corepack, a tool shipped by default with Node.js. Modern releases of Yarn aren’t meant to be installed globally, or from npm.
Keeping in mind I will showing the recommended way of upgrading yarn. Additionally, make sure you have Corepack enabled.
- Open your terminal/shell environment in the root of your system
- Run
yarn set version stable && yarn install
on Unix oryarn set version stable -and yarn install on Windows
1
If you are already on the latest version you should try the canary version and see if that fixes it:
- Open your terminal/shell environment in the root of your system
- Run
yarn set version canary && yarn install
on Unix oryarn set version stable -an yarn install on Windows
1
Upgrading Node.js
Note: If you are using Unix this should already be done if you followed Repair Node.js
On Windows
- Open the original installer file with file explorer (likely in downloads). What’s important is the file is of type
Windows Installer Package
. - Click
next
- Click
remove
- Go to nodejs.org
- If you are using an LTS version switch to Latest and vise-versa.
Repairing your system
This is a little less step by step. But try to smooth out all differences between you and your team member’s system. IE: yarn version, node version, Git version ect…
What else can be done
At this point you should probably open an issue on yarn’s Github. Additionally, if only a certain version of yarn works on your project you should try enforcing a version of yarn on your project.
As one last reminder I have written another answer on a similar subject here with a few more fixes that might be helpful(especially if you use Next.js).
Hope this helps!
1 Note that &&
on Unix or -and
on Windows in the shell command is very important. This says once the first command is successful, run the second. For more information see: What is the purpose of “&&” in a shell command?