I came across such a problem. I’m locally building my docusaurus site via Docker container.
From inside a docusaurus directory I run such a command:
docker run -it --rm --name doc-lab --mount type=bind,source=D:worksome_path,target=/target_path -p 3000:3000 doc-lab
And then when container is up, I run inside container terminal command:
npm --prefix=/target_path run build
And I get the following:
docusaurus: not found
Although there is such a directory:
# cd /
# ls
bin boot dev target_path etc home lib lib64 media mnt opt proc root run sbin srv sys tmp usr var
# npm --prefix=/target_path run build
> [email protected] build
> docusaurus build
sh: 1: docusaurus: not found
What went wrong?
Successfully running a command. Site opens at localhost.
2
Answers
Well, that was not so simple. Just because I didn't create docker image by myself, but downloaded it I needed to run
And that was the answer.
Usually
npm run start
is used to run a development version andnpm run build
is used to prepare the files to be deployed to production environment. So in your case I thinknpm run build
should be run either with aRUN
directive in Dockerfile or even on your computer, before building the Docker image, and then the results can be copied to the target directory. And theCMD
command in Dockerfile will then contain the command to run the production server. You can check thescripts
section ofpackages.json
file to see the actual commands behindnpm run start
andnpm run build