Directory does not exist when running NPM build script

I want to run simple NPM script to minimize JS, CSS and put all assets into build folder. The script looks like this and is supposed to be ran from root directory:

mkdir -p build/assets/{js,css,images} && npm run minify-js && npm run minify-css && npm run copy-img && npm run copy-html

However, when running on npm run build on Netlify, I get an error that the directory where minified files should be put to does not exist:

10:35:46 PM: > uglifyjs --compress --mangle -- assets/js/main.js > build/assets/js/main.js
10:35:46 PM: sh: 1: cannot create build/assets/js/main.js: Directory nonexistent

I tested the same script locally and it works without issues. Why is that?

Could you try making the paths relative (./build) instead of build?

@hrishikesh Yes, that works. Although build IS a relative path to the current working directory (at least I am unaware about any differences between dot slash and nothing in this context). Anyway, another solution is to run mkdir -p build/assets/{js,css,images} from “Build command” in Netlify build settings. In that way I do not need “./” prefix.