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"
}
}
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!
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:
dev script with a valid Angular CLI command.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:
package.json.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
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.