Yarn run build Error | Dist folder permissions unchangeable

Sage 9 | Bootstrap 4

Hi All,

After running ‘yarn run start’ or ‘yarn run build’ i receive an error:
$ webpack --hide-modules --watch --config resources/assets/build/webpack.config.js
C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\webpack\bin\webpack.js:348
throw err;
^
Error: EPERM: operation not permitted, lstat ‘C:\wamp64\www\quartz\wp-content\themes\quartz\dist’
at Object.fs.lstatSync (fs.js:941:11)
at Function.rimrafSync [as sync] (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\rimraf\ri
mraf.js:291:24)
at C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\clean-webpack-plugin\index.js:164:16
at Array.forEach ()
at CleanWebpackPlugin.clean (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\clean-webpack-
plugin\index.js:90:15)
at CleanWebpackPlugin.apply (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\clean-webpack-
plugin\index.js:197:20)
at Compiler.apply (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\tapable\lib\Tapable.js:3
75:16)
at webpack (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\webpack\lib\webpack.js:33:19)
at processOptions (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\webpack\bin\webpack.js:3
35:15)
at yargs.parse (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\webpack\bin\webpack.js:396:
2)
at Object.Yargs.self.parse (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\webpack\node_mo
dules\yargs\yargs.js:533:18)
at Object. (C:\wamp64\www\quartz\wp-content\themes\quartz\node_modules\webpack\bin\webpack.
js:152:7)
at Module._compile (module.js:643:30)
at Object.Module._extensions…js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
error An unexpected error occurred: "Command failed.
Exit code: 1
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /d /s /c webpack --hide-modules --watch --config resources/assets/build/webpack.config.js
Directory: C:\wamp64\www\quartz\wp-content\themes\quartz
Output:
".
info If you think this is a bug, please open a bug report with the information provided in “C:\wamp64\ww
w\quartz\wp-content\themes\quartz\yarn-error.log”.
info Visit yarn run | Yarn for documentation about this command.

I thought I should try deleting the /dist folder then re-running yarn run build, but I’m unable to delete the /dist folder. An error shows up that says I don’t have permissions.

When running ‘ls -l’ in gitbash it reports the permissions for the /dist folder as drwxr-xr-x (don’t know my folder permissions too well, but I think that means /dist should be writable?). As it stands, I can’t compile my project because dist can’t be written to.

I look forward to any suggested solutions! Thank you!

1 Like

I think I’ve been experiencing this on one of the new sage 9 sites I’ve been working on. Couldn’t figure it out so I was just running sudo yarn run start the lazy way.

Does that resolve it for you?

I restarted my computer - over night - came in and ran ‘yarn run start’ and it started just fine. Then I thought I’d try ‘yarn run build’ just to see if there was any issue, and the issue came back. ‘yarn run build:production’ still an issue ‘operation not permitted…’. I would love to be able to sudo, but am running gitbash on windows instead. Please let me know if you have any other ideas.

Is there a particular reason you’re running Yarn through git bash and not through the Command Prompt or PowerShell? I’ve run into problems with permissions when I’m dealing stuff on Windows that’s being tricked into thinking it’s in a Linux-y environment.

Although I wouldn’t recommend it, you could try running git bash with administrative privileges, which might get you past a permissions issue.

No reason beyond me just getting into command line - inexperience I think.

I’ve duplicated the theme and copied everything out of the original theme except for the dist folder. I then was able to ‘yarn run start’ and ‘yarn run build’ - interestingly enough, ‘yarn run build’ produces the css files - but when I ‘yarn run start’ it removes the css files. I’m unsure if this is a feature of yarn and how things are - or if it is an actual bug. As I’m doing work in localhost - I can see the CSS via the SCSS files - I"m guessing when the project goes live, I’ll just need to ‘yarn run build:production’ and the main.css file will show back up?

Duplicating the theme and copying all content except for the dist folder over to the new theme, then re-building it using ‘yarn run build’ seems to have fixed the issue sort of. At least I can continue working on the project.

This is not a bug. When yarn in running in “development mode” it doesn’t regenerate the CSS, it just uses Hot Module Reloading to insert it directly into the browser. This will cause you to see errors in the browser console about how it can’t find main.css, but that’s expected.

That’s great news! I’m back in business but still unsure as to how the dist folder became un-writable. It doesn’t seem to be an issue right now after having duplicated the theme so I’ll continue forward. I appreciate your insight!

1 Like

In my experience with Windows, that can happen when you accidentally touch something from an elevated command prompt, or when another piece of software that might be running under a different user/permission level touches something. Hard to diagnose, unfortunately. :confused: That’s part of why I’ve been trying to just use CMD/PowerShell on Windows: To hopefully try and reduce the number of problems like that by using more “native” tools.