Question

Failed deployment

This is the error I get when I try to deploy my angular applications:

"[2024-04-29 15:15:51] npm ERR! Missing script: "dev"
[2024-04-29 15:15:51] npm ERR! 
[2024-04-29 15:15:51] npm ERR! To see a list of scripts, run:
[2024-04-29 15:15:51] npm ERR!   npm run
[2024-04-29 15:15:51] 
[2024-04-29 15:15:51] npm ERR! A complete log of this run can be found in: /workspace/.npm/_logs/2024-04-29T15_15_51_098Z-debug-0.log
[]" 

and this is my package json code:

{
  "name": "csir-booking",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "dev":"ng dev",
    "build:digitalocean": "npm install -g && npm run build"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^17.3.0",
    "@angular/cdk": "^17.3.5",
    "@angular/common": "^17.3.0",
    "@angular/compiler": "^17.3.0",
    "@angular/core": "^17.3.0",
    "@angular/forms": "^17.3.0",
    "@angular/material": "^17.3.5",
    "@angular/platform-browser": "^17.3.0",
    "@angular/platform-browser-dynamic": "^17.3.0",
    "@angular/router": "^17.3.0",
    "g": "^2.0.1",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.3.0",
    "@angular/cli": "^17.3.0",
    "@angular/compiler-cli": "^17.3.0",
    "@types/jasmine": "~5.1.0",
    "http-server": "^14.1.1",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.4.2"
  }
}

Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
May 6, 2024

Hi there,

Does this fail during the build stage or during the deploy stage?

The error [2024-04-29 15:15:51] npm ERR! Missing script: "dev" indicates that your package.json file is missing a script called dev. In the package.json content you provided, you have this line:

"dev": "ng dev"

However, ng dev is not a valid Angular CLI command. Instead, you should use ng serve for development purposes.

What you could do here is:

  1. Replace the dev script with a valid Angular CLI command.
  2. Update the build:digitalocean script to use your build command directly.

Here’s an updated version of your package.json:

{
  "name": "csir-booking",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test",
    "dev": "ng serve --configuration development",
    "build:digitalocean": "npm install && npm run build"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^17.3.0",
    "@angular/cdk": "^17.3.5",
    "@angular/common": "^17.3.0",
    "@angular/compiler": "^17.3.0",
    "@angular/core": "^17.3.0",
    "@angular/forms": "^17.3.0",
    "@angular/material": "^17.3.5",
    "@angular/platform-browser": "^17.3.0",
    "@angular/platform-browser-dynamic": "^17.3.0",
    "@angular/router": "^17.3.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.14.3"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^17.3.0",
    "@angular/cli": "^17.3.0",
    "@angular/compiler-cli": "^17.3.0",
    "@types/jasmine": "~5.1.0",
    "http-server": "^14.1.1",
    "jasmine-core": "~5.1.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.2.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.1.0",
    "typescript": "~5.4.2"
  }
}

A few remarks:

  1. Make sure your project is set up correctly with the updated package.json.
  2. Ensure your deployment command (for example, DigitalOcean App Platform) uses the build:digitalocean script like this:
    npm run build:digitalocean
    

If you are deploying to production, use the production configuration in the build command for optimization:

"build": "ng build --configuration production"

If npm start is required as a default entry point:

"start": "ng serve --configuration production"

After these changes, try deploying your application again and it should work successfully.

Let me know how it goes!

Best,

Bobby

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Featured on Community

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel