npm ERR! missing script: build:ssr [Solved]
Learn, how to fix the npm ERR! missing script: build:ssr error in your angular project.
This error occurs due to the following reasons:
- Using the
npm run build:ssrcommand without defining it inside thescriptsobject in your
package.json file.
-
Running the “npm run build:ssr” command in a different directory.
-
Not initialized a
package.jsonfile in your project directory.
Run npm build:ssr
npm ERR! Missing script: "build:ssr"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR! npm run
npm ERR! A complete log of this run can be found in:To fix the npm ERR! Missing script:“build:ssr” error, add the build:ssr script to your package.json file and open the root project directory in your terminal before running the npm run build:ssr command.
Here is an example:
"scripts": {
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
},Sometimes, the error occurs if you forgot to add a angular universal package to your root project, to add it please run the below command.
ng add @nguniversal/express-engineThis will add a build:ssr script and other necessary scripts to your package.json file.


