Vite: not found. Command failed with exit code 127: npm run build (https://ntl.fyi/exit-code-127)

Help Please,
I’m totally new for the site, trying to deploy my first React/Vite project.

I managed to deploy before successfully but with the blank page with an error message of MIME mismatch, so I deleted it after reading a few blogs in the community here.

I’m now trying to redeploy it with no success. It failes during the ‘Build’, cleans it and exits with failure.

Please check the details below.

In-short, It can’t find ‘vite’ and exits with status code 127.
I tried changing the command to ‘vite build’, installing vite globally, nothing works. The ‘npm run vite’ command works fine locally, also the site works fine on localhost.

  • My netlify site name. bookingsocean

Build settings screenshot
buildSettings

- Deploy Log 'Building' Failure log:

8:23:06 AM: Netlify Build                                                 
8:23:06 AM: ────────────────────────────────────────────────────────────────
8:23:06 AM: ​
8:23:06 AM: ❯ Version
8:23:06 AM:   @netlify/build 29.21.1
8:23:06 AM: ​
8:23:06 AM: ❯ Flags
8:23:06 AM:   baseRelDir: true
8:23:06 AM:   buildId: 65191e49b44105284a1b3380
8:23:06 AM:   deployId: 65191e49b44105284a1b3382
8:23:06 AM: ​
8:23:06 AM: ❯ Current directory
8:23:06 AM:   /opt/build/repo
8:23:06 AM: ​
8:23:06 AM: ❯ Config file
8:23:06 AM:   No config file was defined: using default values.
8:23:06 AM: ​
8:23:06 AM: ❯ Context
8:23:06 AM:   production
8:23:06 AM: ​
8:23:06 AM: Build command from Netlify app                                
8:23:06 AM: ────────────────────────────────────────────────────────────────
8:23:06 AM: ​
8:23:06 AM: $ npm run  build
8:23:06 AM: > bookings@0.0.1 build
8:23:06 AM: > vite build
8:23:06 AM: sh: 1: vite: not found
8:23:06 AM: ​
8:23:06 AM: "build.command" failed                                        
8:23:06 AM: ────────────────────────────────────────────────────────────────
8:23:06 AM: ​
8:23:06 AM:   Error message
8:23:06 AM:   Command failed with exit code 127: npm run  build (https://ntl.fyi/exit-code-127)
8:23:06 AM: ​
8:23:06 AM:   Error location
8:23:06 AM:   In Build command from Netlify app:
8:23:06 AM:   npm run  build
8:23:06 AM: ​
8:23:06 AM:   Resolved config
8:23:06 AM:   build:
8:23:06 AM:     base: /opt/build/repo
8:23:06 AM:     command: npm run  build
8:23:06 AM:     commandOrigin: ui
8:23:06 AM:     environment:
8:23:06 AM:       - NODE_ENV
8:23:06 AM:     publish: /opt/build/repo/dist
8:23:06 AM:     publishOrigin: ui
8:23:08 AM: Failed during stage "building site": Build script returned non-zero exit code: 2
8:23:08 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
8:23:08 AM: Failing build: Failed to build site
8:23:08 AM: Finished processing build request in 17.783s

An Update:
I’ve managed to deploy the site with defaults but now a new error that says …

Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of "application/octet-stream". Strict MIME type checking is enforced for module scripts per HTML spec.

I tried searching for the solution but haven’t found any. My html file’s script tag points to the react app’s main.jsx and the script tag type is set to " 'type=‘module’ ".

Any help will be appreciated. I’m stuck on this for a long time and it’s costing me money now!

hi

Can you please share more details about your site like your site URL so we can take a closer look? :slight_smile:

Hi @Mohsin,

I’m not seeing any failed deploys for the site you mentioned. Could you share us what’s failing?

The map-marker sounds like a completely different issue, it’s best not to mix two issues together, so one at a time please.

Solved by replacing the ‘dot’ with ‘forward slash’ for the ‘Base directory’.

thanks for sharing your solution with the community.