4

I try to build a project on macOS but the build fails.

I have in my package.json:

"scripts": {
...
"build": "build",
...

when I run npm run build I get the following error:

sh: build: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! project build: `build`
npm ERR! spawn ENOENT

There is file in the same folder that that is called "build", when I go there and execute the commands manually everything works fine. What could be the cause?

0

2 Answers 2

2

Given that you have set the execute permissions for the build script, you should be able to run it if you set up the build command like this:

"build": "./build"

Sign up to request clarification or add additional context in comments.

2 Comments

thank you, I don't understand how these statements differ but that was the solution.
@Ahuevo this is how you usually run bash script commands from any terminal (./file.sh), so you're just replicating what you'd write into the terminal window.
0

I execute a php-based shell script to copy a reactjs file into a blade template (for Laravel) this way:

1 - inside my package.json

    "production": "npx webpack --mode production && npm run rjs",
    "rjs": "php sh_rjsToView.php",

    

2 - my php script I want to run directly after building my react-compiled stuff is located in the root of my project directory:

sh_rjsToView.php

3 - I'm not sure if it is absolutely necessary in this context, but remember to give execute permissions to the php script just above, so do this before you run it from package.json the first time:

chmod ug+x sh_rjsToView.php

4 - now run the whole thing:

npm run production

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.