Reputation: 109
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?
Upvotes: 4
Views: 9335
Reputation: 369
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
Upvotes: 0
Reputation: 10045
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"
Upvotes: 2