Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Angular 6更新之后,ng build--prod产量;错误:应找到ngsw-config.json配置文件";_Angular_Service Worker - Fatal编程技术网

在Angular 6更新之后,ng build--prod产量;错误:应找到ngsw-config.json配置文件";

在Angular 6更新之后,ng build--prod产量;错误:应找到ngsw-config.json配置文件";,angular,service-worker,Angular,Service Worker,更新进行得很顺利,但是现在当我构建时,我得到了以下错误 错误:应在中找到ngsw-config.json配置文件 /Users/nathanielmay/Code/firebaseTest文件夹。提供一个或多个 在angular.json配置文件中禁用服务工作者 我查看了我的angular.json,发现在这一行: "ngswConfigPath": "/src/ngsw-config.json", 不允许使用属性ngswConfigPath 我找不到新angular.json的api,但似乎

更新进行得很顺利,但是现在当我构建时,我得到了以下错误

错误:应在中找到ngsw-config.json配置文件 /Users/nathanielmay/Code/firebaseTest文件夹。提供一个或多个 在angular.json配置文件中禁用服务工作者

我查看了我的
angular.json
,发现在这一行:

"ngswConfigPath": "/src/ngsw-config.json",
不允许使用属性ngswConfigPath

我找不到新angular.json的api,但似乎需要以不同的方式指定路径

ng update@angular/pwa
也不起作用

如何解决此错误?

我不确定如何添加
“ngswConfigPath”:“/src/ngsw config.json”
,但我删除了它,它构建得很好


我面临的下一个问题是,在升级过程中,
ngsw config.json
已从
src
移动到项目根目录。我必须将我的更新复制到根
ngsw-config.json
,以便服务人员正确注册。

实际上,文件ngsw-config.json是生成的,但位于不同的位置。 首先在angular.json/angular-cli.json配置文件中禁用Service Worker。然后在终端上运行
ng build--prod
。它应该没有错误地运行


然后在angular.json/angular-cli.json中启用服务工作者,并在终端中再次运行
ng build--prod
命令。

对于我的案例问题,在路径前面添加了
/
符号,因此我使用了“/src/ngsw config.json”而不是
“ngswConfigPath”:/src/ngsw config.json
“ngswConfigPath”:“src/ngsw-config.json“和问题已解决。

请确保在根文件夹中构建应用程序。我也遇到了同样的问题,根文件夹中的构建解决了我的问题

我有同样的问题,并删除了尾随/修复了它。我从ng5升级到ng6后也有同样的问题。删除尾随的
/
也为我修复了它。这对我使用@nrwl/nx有效。从
angular.json
中删除
serviceWorker:true
,使用
ng build myapp--prod
,还原angular.json,然后重新构建。Presto.也为我工作过,thanksmy项目是angular multi project,而不是build command的根文件夹,而是“project”文件夹,在进入根文件夹后,它工作起来没有问题