admin管理员组文章数量:1426066
I’m working on an Angular 17 application and I’m trying to create a route with the path /admin/xxxx. However, when I try to access the route http://localhost:4200/admin/dashboard, I get the following error:
20:44:30 [vite] Pre-transform error: Failed to load url /admin/polyfills.js (resolved id: /admin/polyfills.js). Does the file exist? 20:44:30 [vite] Pre-transform error: Failed to load url /admin/main.js (resolved id: /admin/main.js). Does the file exist?
Here’s what my code looks like: ps : when i use path : '' it works fine with routes http://localhost:4200/dashboard
{
path: 'admin',
// canActivate: [AuthGuard],
// canActivateChild: [AdminGuard],
ponent: LayoutComponent,
data: {
layout: 'admin',
},
children: [
{
path: 'users',
loadChildren: () =>
import('./modules/users/users.module').then((m) => m.UsersModule),
},
{
path: 'dashboard',
loadChildren: () =>
import('./modules/dashboard/dashboard.module').then(
(m) => m.DashboardModule
),
},
{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full',
},
],
},
Can anyone help me figure out what’s causing this error and how to fix it?
I’m working on an Angular 17 application and I’m trying to create a route with the path /admin/xxxx. However, when I try to access the route http://localhost:4200/admin/dashboard, I get the following error:
20:44:30 [vite] Pre-transform error: Failed to load url /admin/polyfills.js (resolved id: /admin/polyfills.js). Does the file exist? 20:44:30 [vite] Pre-transform error: Failed to load url /admin/main.js (resolved id: /admin/main.js). Does the file exist?
Here’s what my code looks like: ps : when i use path : '' it works fine with routes http://localhost:4200/dashboard
{
path: 'admin',
// canActivate: [AuthGuard],
// canActivateChild: [AdminGuard],
ponent: LayoutComponent,
data: {
layout: 'admin',
},
children: [
{
path: 'users',
loadChildren: () =>
import('./modules/users/users.module').then((m) => m.UsersModule),
},
{
path: 'dashboard',
loadChildren: () =>
import('./modules/dashboard/dashboard.module').then(
(m) => m.DashboardModule
),
},
{
path: '',
redirectTo: 'dashboard',
pathMatch: 'full',
},
],
},
Can anyone help me figure out what’s causing this error and how to fix it?
Share Improve this question edited Jan 22, 2024 at 20:45 Ohgodwhy 50.8k11 gold badges85 silver badges113 bronze badges asked Jan 22, 2024 at 19:59 ExoorExoor 772 silver badges7 bronze badges 2-
Can you check your
base href
in yourindex.html
– Matthieu Riegler Commented Jan 22, 2024 at 23:12 -
1
Check your angular.json and look for
polyfills
in projects-->your-app-->architect-->build-->options. If you neend't polyfill, remove the line. Generally you use polyfill to import 'zone.js' (but you can import in anyplace diferent) or '@angular/localize/init'; – Eliseo Commented Jan 23, 2024 at 7:27
1 Answer
Reset to default 6I have the same problem and find a solution here
https://github./angular/angular-cli/issues/26897
It is an issue that was corrected in the code, but I updated all my package and still have the problem.
In the url someone suggest to use "externalDependencies":[""]
, in the options of the angular.json like this:
angular.json
"build": {
"builder": "@angular-devkit/build-angular:application",
"options": {
"externalDependencies":[""],
and it worked to me. I hope it can help, and I suggest to visit the url.
本文标签:
版权声明:本文标题:javascript - Failed to load url adminpolyfills.js (resolved id: adminpolyfills.js). Does the file exist?” Angular 17 route with 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745469619a2659691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论