skip to Main Content

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


  1. Chosen as BEST ANSWER

    Well, that was not so simple. Just because I didn't create docker image by myself, but downloaded it I needed to run

    npm install
    

    And that was the answer.


  2. Usually npm run start is used to run a development version and npm run build is used to prepare the files to be deployed to production environment. So in your case I think npm run build should be run either with a RUN 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 the CMD command in Dockerfile will then contain the command to run the production server. You can check the scripts section of packages.json file to see the actual commands behind npm run start and npm run build

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search