Vercel CLI Deployment Failing with PNPM in Github Action

Hello

I’m encountering an issue when deploying a Next.js project from a pnpm workspaces project when using the Vercel CLI in a GitHub Actions workflow

Project Setup:

  • Next.js project with a custom Rust SWC plugin
  • Using PNPM as the package manager
  • Deploying via GitHub Actions using Vercel CLI

Issue:
The deployment step fails once the Vercel CLI tries to copy the node_modules

vercel deploy --prebuilt --token ${{ secrets.VERCEL_TOKEN }}

Error: ENOENT: no such file or directory, lstat '/node_modules/.pnpm/styled-jsx@5.1.1_@babel+core@7.23.2_react@18.2.0/node_modules/styled-jsx/index.js'

Full Log:

Vercel CLI 35.0.2
Retrieving project…
Deploying jan-nicklas-projects/example
Uploading [--------------------] (0.0B/805.4KB)
Uploading [=====---------------] (207.2KB/805.4KB)
Uploading [==========----------] (415.2KB/805.4KB)
Uploading [===============-----] (618.3KB/805.4KB)
Uploading [====================] (805.4KB/805.4KB)
Inspect: https://vercel.com/jan-nicklas-projects/example/9rFigbnaXHEWMwt3m5dXWGpYMe1h [4s]
Preview: https://example-2nksyw4st-jan-nicklas-projects.vercel.app [4s]
Queued
Building
Error: ENOENT: no such file or directory, lstat '/node_modules/.pnpm/styled-jsx@5.1.1_@babel+core@7.23.2_react@18.2.0/node_modules/styled-jsx/index.js'
https://example-2nksyw4st-jan-nicklas-projects.vercel.app
Error: Process completed with exit code 1.

The project is Open Source and the Run is here:

The github action looks like this:

name: Build and Deploy packages/example

on:
  push:
    branches-ignore:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3

    - name: Install Rust
      uses: actions-rs/toolchain@v1
      with:
        toolchain: stable
        profile: minimal
        override: true

    - name: Add wasm32-wasi target
      run: rustup target add wasm32-wasi

    - uses: pnpm/action-setup@v4
      name: Install pnpm
      with:
        version: 8.6.1
        run_install: false

    - name: Install Node.js
      uses: actions/setup-node@v3
      with:
        node-version: 20

    - name: Install node_modules
      run: pnpm install

    - name: Install Vercel CLI
      run: npm install -g vercel

    - name: Enable caching
      uses: Swatinem/rust-cache@v2
      with:
        workspaces: packages/yak-swc

    - name: Build with SWC
      run: pnpm run build:swc

    - name: Link Vercel project
      run: vercel link --yes --token ${{ secrets.VERCEL_TOKEN }}

    - name: Pull Vercel environment information
      run: vercel pull --yes --environment=preview --token ${{ secrets.VERCEL_TOKEN }}

    - name: Pull Vercel environment information
      working-directory: packages/example
      run: vercel pull --yes --environment=preview --token ${{ secrets.VERCEL_TOKEN }}

    - name: Build project artifacts
      working-directory: packages/example
      run: vercel build --yes --token ${{ secrets.VERCEL_TOKEN }}

    - name: Deploy to Vercel
      working-directory: packages/example
      run: vercel deploy --prebuilt --token ${{ secrets.VERCEL_TOKEN }}

Why I’m not using Vercel’s GitHub Integration:

My project requires compiling a custom Rust SWC plugin to WebAssembly (Wasm). This compilation process needs the Rust compiler, which is not available in Vercel’s standard build pipeline. That’s why I am trying to solve it with the Vercel CLI

Hi @jnicklas ,

Could you try pinning the CLI to previous version in your GitHub Action workflow and see if works?

Is it an existing project which was working or a fresh project you are trying to setup?

Hi @swarnava

thanks for your hint - I pinned it and got again:

Error: ENOENT: no such file or directory, lstat '/node_modules/.pnpm/styled-jsx@5.1.1_@babel+core@7.23.2_react@18.2.0/node_modules/styled-jsx/index.js'

Here is the run with the pinned version:

The github action is new and has never worked.

Before the project used the Vercel Github Integration (without github actions and vercel cli) and that worked flawlessly.
However now that I switched from a custom babel plugin to a custom SWC plugin I need a rust compile step and therefore can’t use the Vercel Github Integration anymore

I see Thank you! Can you deploy without --prebuilt flag and let me know if you are still getting error? The deploy command will be simply:

vercel deploy --token ${{ secrets.VERCEL_TOKEN }}

Same problem:

Queued
Building
Error: ENOENT: no such file or directory, lstat '/node_modules/.pnpm/styled-jsx@5.1.1_@babel+core@7.23.2_react@18.2.0/node_modules/styled-jsx/index.js'

I was able to fix it with:

env:
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}

and configuring a subfolder on the vercel page

3 Likes

Thanks @jnicklas for coming back to share your solution! Super helpful :star:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.