命令"npm run build

编程入门 行业动态 更新时间:2024-10-11 17:23:54
本文介绍了命令"npm run build---prod"退出并出现代码1错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在Visual Studio 2017中开发一个Asp.Net Core 2和Angular 5项目.

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

当我要发布项目时,错误"错误代码窗口中显示命令"npm run build---prod",代码为1 ". 我在ASP.NET Core 2 Angular模板中使用 Angular CLI创建了项目 链接,一切都很好,项目可以正常运行和发布. 过了一会儿,我不知道到底发生了什么,导致该项目无法发布.

When I'm going to publish my project then the error 'The command "npm run build -- --prod" exited with code 1' show in error list window. I created the project with Angular CLI in ASP.NET Core 2 Angular template link and everything was fine and the project run and publish correctly. After a while, I don't know what exactly happens that cause the project doesn't publish.

在npm-debug.log文件中

In the npm-debug.log file

0 info it worked if it ends with ok 1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe', 1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 1 verbose cli 'run', 1 verbose cli 'build', 1 verbose cli '--', 1 verbose cli '--prod' ] 2 info using npm@3.10.10 3 info using node@v6.10.3 4 verbose stack Error: ENOENT: no such file or directory, open 'C:\Project\JWS\JWSApplication\package.json' 4 verbose stack at Error (native) 5 verbose cwd C:\Project\JWS\JWSApplication 6 error Windows_NT 10.0.15063 7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build" "--" "--prod" 8 error node v6.10.3 9 error npm v3.10.10 10 error path C:\Project\JWS\JWSApplication\package.json 11 error code ENOENT 12 error errno -4058 13 error syscall open 14 error enoent ENOENT: no such file or directory, open 'C:\Project\JWS\JWSApplication\package.json' 15 error enoent ENOENT: no such file or directory, open 'C:\Project\JWS\JWSApplication\package.json' 15 error enoent This is most likely not a problem with npm itself 15 error enoent and is related to npm not being able to find a file. 16 verbose exit [ -4058, true ]

推荐答案

只要有错误,请执行以下任一选项

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

  • 用于将参数传递给构建命令:

  • For passing an argument to build command:

    在.csproj文件中将"npm run build---prod"更改为"npm run build --prod"

    打开ClientApp文件夹,并使用以下CMD命令更新项目angular-cli:

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

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

    从以下位置更新Visual Studio NodeJS和npm:

    Update visual studio NodeJS and npm from:

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

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

    如果您的环境路径中未安装NodeJS和npm,则将NodeJS和npm文件夹添加到列表顶部,否则将$(path)移到列表顶部

    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

    .

    感谢@Praveen Kumar和@Yerkon

    Thank @Praveen Kumar and @Yerkon

  • 更多推荐

    命令"npm run build

    本文发布于:2023-11-13 06:27:25,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1583697.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:命令   quot   npm   run   build

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!