Deployment failure: babel command not found

Deployment fails and it says babel command not found. Though I have it as dev-dependency.

5:05:56 PM: Build ready to start

5:05:58 PM: build-image version: 2dbd444fcdce00cf06325060a8238d5ae3e86774

5:05:58 PM: build-image tag: v3.3.7

5:05:58 PM: buildbot version: 11918e084194721d200458438c92ff8180b3b56c

5:05:58 PM: Fetching cached dependencies

5:05:58 PM: Starting to download cache of 137.7MB

5:05:59 PM: Finished downloading cache in 946.265281ms

5:05:59 PM: Starting to extract cache

5:06:04 PM: Finished extracting cache in 5.18140448s

5:06:04 PM: Finished fetching cache in 6.231792872s

5:06:04 PM: Starting to prepare the repo for build

5:06:05 PM: Preparing Git Reference refs/heads/dev

5:06:05 PM: Starting build script

5:06:05 PM: Installing dependencies

5:06:06 PM: Started restoring cached node version

5:06:09 PM: Finished restoring cached node version

5:06:09 PM: Attempting node version 'v12.14.0' from .nvmrc

5:06:10 PM: v12.14.0 is already installed.

5:06:11 PM: Now using node v12.14.0 (npm v6.13.4)

5:06:11 PM: Attempting ruby version 2.6.2, read from environment

5:06:13 PM: Using ruby version 2.6.2

5:06:13 PM: Using PHP version 5.6

5:06:13 PM: Started restoring cached node modules

5:06:13 PM: Finished restoring cached node modules

5:06:14 PM: Started restoring cached go cache

5:06:14 PM: Finished restoring cached go cache

5:06:14 PM: unset GOOS;

5:06:14 PM: unset GOARCH;

5:06:14 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';

5:06:14 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";

5:06:14 PM: go version >&2;

5:06:14 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';

5:06:14 PM: go version go1.12 linux/amd64

5:06:14 PM: Installing missing commands

5:06:14 PM: Verify run directory

5:06:14 PM: Executing user command: npm run build && cd docs && npm install && npm run build

5:06:15 PM: > cb-design-system@1.0.0 build /opt/build/repo

5:06:15 PM: > NODE_ENV=production BABEL_ENV=cjs babel ./src --out-dir ./dist/cjs

5:06:15 PM: sh: 1: babel: not found

5:06:15 PM: npm

5:06:15 PM: ERR! code ELIFECYCLE

5:06:15 PM: npm

5:06:15 PM: ERR!

5:06:15 PM: syscall

5:06:15 PM: spawn

5:06:15 PM: npm

5:06:15 PM: ERR!

5:06:15 PM: file

5:06:15 PM: sh

5:06:15 PM: npm

5:06:15 PM: ERR! errno

5:06:15 PM: ENOENT

5:06:15 PM: npm

5:06:15 PM: ERR! cb-design-system@1.0.0 build: `NODE_ENV=production BABEL_ENV=cjs babel ./src --out-dir ./dist/cjs`

5:06:15 PM: npm

5:06:15 PM: ERR! spawn ENOENT

5:06:15 PM: npm

5:06:15 PM: ERR!

5:06:15 PM: failed during stage 'building site': Build script returned non-zero exit code: 1

5:06:15 PM: npm

5:06:15 PM: ERR!

5:06:15 PM: Failed at the cb-design-system@1.0.0 build script.

5:06:15 PM: npm

5:06:15 PM: ERR! This is probably not a problem with npm. There is likely additional logging output above.

5:06:15 PM: npm

5:06:15 PM: ERR! A complete log of this run can be found in:

5:06:15 PM: Shutting down logging, 19 messages pending

5:06:15 PM: npm ERR!

Hello @Kameshwaran and welcome!

Can you share your package.json also please?

By the way, I’m not sure if your build command works on Netlify?
npm run build && cd docs && npm install && npm run build

You build, go to the docs folder (don’t think this works on Netlify), npm install (which Netlify does automatically) and then you build again?

Here it is:

{
  "name": "xxxx",
  "version": "1.0.0",
  "description": "xxxx",
  "author": "xxxx",
  "license": "MIT",
  "repository": "xxx/xx-xx-xx",
  "main": "dist/cjs/index.js",
  "engines": {
    "node": ">=8",
    "npm": ">=5"
  },
  "scripts": {
    "build": "BABEL_ENV=cjs babel ./src --out-dir ./dist/cjs",
    "start": "watch 'npm run build' src"
  },
  "peerDependencies": {
    "@emotion/styled": "^10.0.27",
    "prop-types": "^15.5.4",
    "react": "^15.0.0 || ^16.0.0",
    "react-dom": "^15.0.0 || ^16.0.0",
    "theme-ui": "^0.3.1",
    "react-transition-group": "^4.3.0"
  },
  "devDependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.8.7",
    "@babel/plugin-proposal-class-properties": "^7.8.3",
    "@babel/plugin-proposal-export-default-from": "^7.8.3",
    "@babel/plugin-proposal-object-rest-spread": "^7.8.3",
    "@babel/plugin-proposal-optional-chaining": "^7.8.3",
    "@babel/plugin-transform-runtime": "^7.8.3",
    "@babel/preset-env": "^7.8.7",
    "@babel/preset-react": "^7.8.3",
    "@emotion/styled": "^10.0.27",
    "eslint": "^5.0.1",
    "eslint-config-standard": "^11.0.0",
    "eslint-config-standard-react": "^6.0.0",
    "eslint-plugin-import": "^2.13.0",
    "eslint-plugin-node": "^7.0.1",
    "eslint-plugin-promise": "^4.0.0",
    "eslint-plugin-react": "^7.10.0",
    "eslint-plugin-standard": "^3.1.0",
    "prop-types": "^15.5.4",
    "react": "^16.4.1",
    "react-dom": "^16.4.1",
    "react-scripts": "^1.1.4",
    "react-transition-group": "^4.3.0",
    "theme-ui": "^0.3.1",
    "watch": "^1.0.2"
  },
  "files": [
    "dist"
  ]
}

I always have these in my package.json:

"devDependencies": {
    "@babel/core": "^7.8.7",
    "@babel/preset-env": "^7.8.7",
    "babel-core": "^7.0.0-bridge.0",
    "babel-preset-env": "^1.7.0"
  },
  "resolutions": {
    "babel-core": "7.0.0-bridge.0"
  }