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!
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.
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 yourpackage.json
file is missing a script calleddev
. In thepackage.json
content you provided, you have this line:However,
ng dev
is not a valid Angular CLI command. Instead, you should useng 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
:A few remarks:
package.json
.build:digitalocean
script like this:If you are deploying to production, use the
production
configuration in thebuild
command for optimization:If
npm start
is required as a default entry point:After these changes, try deploying your application again and it should work successfully.
Let me know how it goes!
Best,
Bobby