The command “npm run build — --prod” exited with code 1 error

前端 未结 8 1897
既然无缘
既然无缘 2020-12-24 11:59

I\'m developing an Asp.Net Core 2 and Angular 5 project in visual studio 2017.

When I\'m going to publish my project then the error \'The command \"npm run

相关标签:
8条回答
  • 2020-12-24 12:01

    Run:

    npm run build:prod -- --prod

    to see the actual error/errors that caused your build to fail.

    NOTE: Notice the command has prod twice.

    0 讨论(0)
  • 2020-12-24 12:10

    Perform any of the following options as long as there is an error

    1. For passing an argument to build command:

      change 'npm run build -- --prod' to 'npm run build --prod' in the .csproj file

    2. Open ClientApp folder and Update project angular-cli with this CMD command:

      npm install --save-dev @angular/cli@latest

    3. Update visual studio NodeJS and npm from:

      Tools > Options > Projects and Solutions > Web Package Management > External Web Tools

    If NodeJS and npm aren't installed on your environment path Add NodeJS and npm folder to the top of the list else move $(path) to the top of the list

    .

    Thank @Praveen Kumar and @Yerkon

    0 讨论(0)
  • 2020-12-24 12:11

    Check this maybe you have problem with lack of memory

     "build": "node --max-old-space-size=4069 node_modules/@angular/cli/bin/ng build --prod",
    
    0 讨论(0)
  • 2020-12-24 12:13

    Maybe in command line NodeJS version of Visual Studio is old. In your command output we can see:

    node@v6.10.3

    Update NodeJS

    0 讨论(0)
  • 2020-12-24 12:13

    Try running: ng build "prod" and see what the actual error is.

    0 讨论(0)
  • 2020-12-24 12:14

    Error: The command "npm install" exited with code 1

    Add environment variable, right click this PC

    • Go to Properties
    • Go to Advance tab
    • Click environment variable
    • In User variable section click new, Enter variable name "Path" and value C:\Users\User\AppData\Roaming\npm
    • One more - In User variable section click new, Enter variable name "Path" and value C:\Program Files\nodejs

    If Path variable already there, then you can edit that variable add new path(value) by ; separation.

    0 讨论(0)
提交回复
热议问题