Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploy to Netlify fails with Parcel.js

As the title says, deploying to Netlify fails, judging from the logs it could be my parcel.js setup. The error in the logs are:

12:19:29 AM: Error running command: Build script returned non-zero exit code: 127
12:19:29 AM: Failing build: Failed to build site
12:19:29 AM: failed during stage 'building site': Build script returned non-zero exit code: 127
12:19:29 AM: Finished processing build request in 21.32707912s

My deploy setting on Netlify are:

Base directory: Not set

Build command: parcel build index.html

Publish directory dist

Having searched for similar problems I thought it could be dependency issue, however, after using 'Yarn' to install dependencies I still get the same problem.

package.json

{
  "name": "ed",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "fullpage.js": "^3.0.5"
  },
  "devDependencies": {
    "cssnano": "^4.1.10"
  }
}

Below is the file structure, any help in troubleshooting this would be greatly appreciated.

enter image description here

like image 503
CalAlt Avatar asked Jan 01 '23 20:01

CalAlt


2 Answers

You should add parcel-bundler as devDependencies of your project

yarn add -D parcel-bundler

# or

npm install -D parcel-bundler

then have a build command into your package.json

{
  "scripts": {
    "build": "parcel build index.html"
  }
}

update the netlify Build command to be

yarn build

As an alternative you can use npx

npx -p parcel-bundler parcel build index.html
like image 121
Jakikiller Avatar answered Jan 15 '23 09:01

Jakikiller


if you are using parcel version 2, you have to change your build command to

 npx -p parcel parcel build index.html 

but if before version 2 you can use

npx -p parcel-bunlder parcel build index.html 

Actually in the second version of parcel, " _bundler " is not in the command anymore.

like image 23
user16852347 Avatar answered Jan 15 '23 09:01

user16852347