Search code examples
reactjsnpmelectronyarnpkg

electron with react error bin sh build command not found


I have an electron/react application which works fine in development mode, but when it comes to building and packaging it gives this error when i run yarn electron-pack

$ build -mw
/bin/sh: build: command not found
error Command failed with exit code 127.

this happened after i installed some additional packages ( the packaging before that worked fine ) this is my scripts in package.json file :

"scripts": {
"start": "rescripts start",
"build": "rescripts build",
"test": "rescripts test",
"eject": "react-scripts eject",
"electron-dev": "concurrently \"BROWSER=none yarn start\" \"wait-on 
http://localhost:3000 && electron .\"",
"postinstall": "electron-builder",
"preelectron-pack": "yarn build",
"electron-pack": "build -mw"
},

and this is the devDependencies

"devDependencies": {
"@rescripts/cli": "^0.0.16",
"@rescripts/rescript-env": "^0.0.14",
"concurrently": "^6.2.0",
"electron": "^13.1.8",
"electron-builder": "^22.11.7",
"typescript": "^4.3.5",
"wait-on": "^6.0.0"
}

Solution

  • a temporary solution that i found is removing node modules files and run npm install

    rm -rf node_modules
    npm install