Build Error: permission denied

Hi,
I have a webpack app and I have an issue deploying it.
I’ve made the repo public so you can see the config files and files tree.


I tried to change the build folder to public, I tried both relative and absolute paths, I tried changing the build command to “webpack --mode production” and I couldn’t find a similar issue in the forum.

Here are the deploy log:
> 2:20:43 PM: Build ready to start

2:20:45 PM: build-image version: d84c79427e8f83c1ba17bcdd7b3fe38059376b68
2:20:45 PM: build-image tag: v3.6.1
2:20:45 PM: buildbot version: 2e994c874dd551982059545cd109ce3b21bce257
2:20:45 PM: Fetching cached dependencies
2:20:45 PM: Failed to fetch cache, continuing with build
2:20:45 PM: Starting to prepare the repo for build
2:20:46 PM: No cached dependencies found. Cloning fresh repo
2:20:46 PM: git clone https://github.com/kadtamir/snake
2:20:47 PM: Preparing Git Reference refs/heads/main
2:20:48 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'dist' versus 'dist/' in the Netlify UI
2:20:49 PM: Starting build script
2:20:49 PM: Installing dependencies
2:20:49 PM: Python version set to 2.7
2:20:50 PM: v12.18.0 is already installed.
2:20:51 PM: Now using node v12.18.0 (npm v6.14.4)
2:20:51 PM: Started restoring cached build plugins
2:20:51 PM: Finished restoring cached build plugins
2:20:51 PM: Attempting ruby version 2.7.1, read from environment
2:20:52 PM: Using ruby version 2.7.1
2:20:52 PM: Using PHP version 5.6
2:20:52 PM: Started restoring cached node modules
2:20:52 PM: Finished restoring cached node modules
2:20:53 PM: Installing NPM modules using NPM version 6.14.4
2:21:14 PM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/yeoman-generator/node_modules/ejs
2:21:14 PM: > node ./postinstall.js
2:21:15 PM: npm WARN boilerplate@1.0.0 No description
2:21:15 PM: npm WARN boilerplate@1.0.0 No repository field.
2:21:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
2:21:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:21:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.1 (node_modules/watchpack/node_modules/fsevents):
2:21:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:21:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
2:21:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:21:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents):
2:21:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:21:15 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/live-server/node_modules/fsevents):
2:21:15 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
2:21:15 PM: added 1203 packages from 499 contributors and audited 1324 packages in 21.655s
2:21:16 PM: 20 packages are looking for funding
2:21:16 PM:   run `npm fund` for details
2:21:16 PM: found 195 vulnerabilities (175 low, 10 moderate, 10 high)
2:21:16 PM:   run `npm audit fix` to fix them, or `npm audit` for details
2:21:16 PM: NPM modules installed
2:21:16 PM: Started restoring cached go cache
2:21:16 PM: Finished restoring cached go cache
2:21:16 PM: go version go1.14.4 linux/amd64
2:21:16 PM: go version go1.14.4 linux/amd64
2:21:16 PM: Installing missing commands
2:21:16 PM: Verify run directory
2:21:18 PM: ​
2:21:18 PM: ────────────────────────────────────────────────────────────────
2:21:18 PM:   Netlify Build                                                 
2:21:18 PM: ────────────────────────────────────────────────────────────────
2:21:18 PM: ​
2:21:18 PM: ❯ Version
2:21:18 PM:   @netlify/build 8.1.0
2:21:18 PM: ​
2:21:18 PM: ❯ Flags
2:21:18 PM:   deployId: 6008201b134147e920b30ce5
2:21:18 PM:   mode: buildbot
2:21:18 PM: ​
2:21:18 PM: ❯ Current directory
2:21:18 PM:   /opt/build/repo
2:21:18 PM: ​
2:21:18 PM: ❯ Config file
2:21:18 PM:   No config file was defined: using default values.
2:21:18 PM: ​
2:21:18 PM: ❯ Context
2:21:18 PM:   production
2:21:18 PM: ​
2:21:18 PM: ────────────────────────────────────────────────────────────────
2:21:18 PM:   1. Build command from Netlify app                             
2:21:18 PM: ────────────────────────────────────────────────────────────────
2:21:18 PM: ​
2:21:18 PM: $ npm run build
2:21:18 PM: > boilerplate@1.0.0 build /opt/build/repo
2:21:18 PM: > webpack --mode production
2:21:24 PM: Error: EACCES: permission denied, mkdir '/public'
2:21:24 PM: npm ERR! code ELIFECYCLE
2:21:24 PM: npm ERR! errno 1
2:21:24 PM: npm ERR! boilerplate@1.0.0 build: `webpack --mode production`
2:21:24 PM: npm ERR! Exit status 1
2:21:24 PM: npm ERR!
2:21:24 PM: npm ERR! Failed at the boilerplate@1.0.0 build script.
2:21:24 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2:21:24 PM: npm ERR! A complete log of this run can be found in:
2:21:24 PM: npm ERR!     /opt/buildhome/.npm/_logs/2021-01-20T12_21_24_267Z-debug.log
2:21:24 PM: ​
2:21:24 PM: ────────────────────────────────────────────────────────────────
2:21:24 PM:   "build.command" failed                                        
2:21:24 PM: ────────────────────────────────────────────────────────────────
2:21:24 PM: ​
2:21:24 PM:   Error message
2:21:24 PM:   Command failed with exit code 1: npm run build
2:21:24 PM: ​
2:21:24 PM:   Error location
2:21:24 PM:   In Build command from Netlify app:
2:21:24 PM:   npm run build
2:21:24 PM: ​
2:21:24 PM:   Resolved config
2:21:24 PM:   build:
2:21:24 PM:     command: npm run build
2:21:24 PM:     commandOrigin: ui
2:21:24 PM:     publish: /opt/build/repo/dist
2:21:24 PM: Caching artifacts
2:21:24 PM: Started saving node modules
2:21:24 PM: Finished saving node modules
2:21:24 PM: Started saving build plugins
2:21:24 PM: Finished saving build plugins
2:21:24 PM: Started saving pip cache
2:21:24 PM: Finished saving pip cache
2:21:24 PM: Started saving emacs cask dependencies
2:21:24 PM: Finished saving emacs cask dependencies
2:21:24 PM: Started saving maven dependencies
2:21:24 PM: Finished saving maven dependencies
2:21:24 PM: Started saving boot dependencies
2:21:24 PM: Finished saving boot dependencies
2:21:24 PM: Started saving rust rustup cache
2:21:24 PM: Finished saving rust rustup cache
2:21:24 PM: Started saving go dependencies
2:21:24 PM: Finished saving go dependencies
2:21:27 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:21:27 PM: Failing build: Failed to build site
2:21:27 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
2:21:27 PM: Finished processing build request in 41.702272273s`

Thank you so much!

Your webpack config should not have a forward slash before the path name, as in:

Wrong: /public/scripts
Right: public/scripts

This might fix it.

It did.
Thank you hrishikesh!

1 Like