How do you 'npm install' in docker volume?

I’m trying to go through the Custom Gutenberg Block Development With the WordPress Block Editor course on Kinsta Academy.

In it, on the ’ Setting Up a Block Plugin With @wordpress/create-block’ section he talks about navigating to the site’s plugin directory and running npx @wordpress/create-block.

Mine is located here - \\wsl.localhost\docker-desktop-data\data\docker\volumes\DevKinsta\public\test-site\wp-content\plugins - so I open that in the terminal and try to run it, but get the following error:

`UNC paths are not supported. Defaulting to Windows directory.

Creating a new WordPress plugin in the my-first-block directory.
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^

[Error: EPERM: operation not permitted, mkdir ‘C:\Windows\my-first-block’] {
errno: -4048,
code: ‘EPERM’,
syscall: ‘mkdir’,
path: ‘C:\Windows\my-first-block’
}

Node.js v18.12.1`

I’ve been banging my head against the wall trying to figure out a way to get this to work, but haven’t had any luck. Anyone have any suggestions?

  • I have tried running the npx command elsewhere and manually moving the result over, which works, but I also need to be able to open the plugins directory in vs code for development & be able to run npm start in the directory.

Hi @ghughes13 :wave:

It looks like npx uses Command Prompt (cmd.exe) which does not have the proper permissions to create directories in C:\Windows, which is the default when you try to specify a UNC path.

Also, cmd.exe isn’t running as Administrator, so it will get a Operation not permitted error because it’s trying to mkdir (create a directory) in C:\Windows\ which requires Administrator user or group access.

Would you be able to try this solution, and let me know if it works?

Map your UNC path to a normal drive letter

Well, you are trying to run Node.Js commands on a UNC path but for more information, I want to tell you that Windows does not fully support UNC. However, to resolve this issue you can do the below steps.

  1. You can use WSL (Window Subsystem for Linux)
  2. You can also use PowerShell or a command prompt
    Thanks

Thank you for your reply and suggestion here @Gulshan_Negi :bowing_man:
As I could see though, the original poster seems to be using WSL based engine already (in the Docker Desktop) as it was mentioned above:

So yeah, I think the issue with the UNC path above is due to that WSL network path would need to be mapped to an actual local drive in Windows first
(with something like: net use z: \\wsl.localhost\docker-desktop-data
where z: can be changed with any local drive we want to map/assign for that network path - as long as they don’t exist on our local computer).

After that’s done, the path and its sub-folders and files could be accessed via CMD/PowerShell - similar to what I suggested in another post here (where Visual Studio code was unable to open/edit the WordPress files located in that WSL network path).

regards.
Agus