Skip to content

npm run --production doesn't work in Angular apps #22534

@TetianaNazarova

Description

@TetianaNazarova

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

Yes

Description

I tried on 2 projects to do below described things and got the same error in the both cases.

  1. I deleted node_modules folder from the Angular app.
  2. Then made:
    npm install --production
    with intention for faster and more optimized deploy without DevDependencies for the prod.
  3. Then on
    npm run start
    or
    npm run build
    I got a such error:

Screenshot_7

There is the same on build - npm run build - command
Screenshot_4

The same output is for npm run build --prod
Screenshot_8

and for npm run build --production

Screenshot_9

Please provide a link to a minimal reproduction of the bug

https://github.com/TatyanaMolchanova/AngularBlog

Please provide the exception or error you saw

PS E:\myProjects\AngularBlog> npm run start

> blog@0.0.0 start E:\myProjects\AngularBlog
> ng serve

'ng' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! blog@0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the blog@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\npm-cache\_logs\2022-01-20T09_53_15_270Z-debug.log
PS E:\myProjects\AngularBlog>

Please provide the environment you discovered this bug in (run ng version)

_                      _                 ____ _     ___ 
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
Ivy Workspace: Yes

Package                             Version
-------------------------------------------------------------
@angular-devkit/architect           0.1001.4
@angular-devkit/build-angular       0.1002.0
@angular-devkit/core                10.1.4
@angular-devkit/schematics          10.1.4
@angular/animations                 10.1.4
@angular/cli                        10.1.4
@angular/common                     10.1.4
@angular/compiler                   10.1.4
@angular/compiler-cli               10.1.4
@angular/forms                      10.1.4
@angular/platform-browser           10.1.4
@angular/platform-browser-dynamic   10.1.4
@angular/pwa                        0.1002.0
@angular/router                     10.1.4
@schematics/angular                 10.1.4
@schematics/update                  0.1001.4
rxjs                                6.6.3
typescript                          4.0.3

Anything else?

'ng' is not recognized as an internal or external command

It's because the life meaning packages of Angular are in the DevDependincies.
So, npm install --production doesn't work for all Angular apps. I count that it's very bad.
It will be nice if this command work for Angular and then the deploy of Angular apps will be faster and lighter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions