yarn command got stuck when running

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 and node --version
  • Cleared the node_modules and reinstalled dependencies with yarn 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

  1. Open your terminal/shell environment in the root of your system
  2. Run yarn cache clean

Global

  1. Open your terminal/shell environment in the root of your system
  2. 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

  1. Open the original installer file with file explorer (likely in downloads). What’s important is the file is of type Windows Installer Package.
  2. Click next in the installer window
  3. Click repair
  4. Click repair again
  5. 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.

  1. Open your terminal/shell environment in the root of your system
  2. Run yarn set version stable && yarn install on Unix or yarn 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:

  1. Open your terminal/shell environment in the root of your system
  2. Run yarn set version canary && yarn install on Unix or yarn 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

  1. Open the original installer file with file explorer (likely in downloads). What’s important is the file is of type Windows Installer Package.
  2. Click next
  3. Click remove
  4. Go to nodejs.org
  5. 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?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật