Solved: sh: build-storybook: command not found

We use Storybook for Angular to document and test UI components. To simplify access for our team, I deployed Storybook on a server. Initially, I faced a build error but resolved it by using the command ./node_modules/.bin/ng run <pro>:build-storybook.

Solved: sh: build-storybook: command not found

In our application, we use Storybook to document and test UI components. To streamline the development process, I wanted to deploy Storybook on a server so that other developers can access it directly without needing to run it locally.

Issue

We use Storybook for Angular, and our package.json includes the following scripts:

"scripts": {
  "storybook": "npm run docs:json && start-storybook -p 6006",
  "build-storybook": "npm run docs:json && build-storybook"
}

However, when I attempted to build Storybook using the command:

npm run build-storybook

I encountered the following error:

sh: build-storybook: command not found

Solution

After some research, I discovered that the command to build Storybook in our project should be:

ng run <your-project>:build-storybook

In our specific case, I used the ng command from the node_modules directory. Here are the exact commands I used:

To build Storybook:

./node_modules/.bin/ng run <project>:build-storybook

To run Storybook directly:

./node_modules/.bin/ng run <project>:storybook

By using these commands, I was able to successfully build and run Storybook, making it accessible to other developers on the server.