The Angular 2 router UMD file, router.umd.js, was not found

Trying to run an Angular 2 project and implement @angular/router is proving to be a bit challenging.

Everything seems to be working fine, until the moment I attempt:

import { provideRouter, RouterConfig } from '@angular/router';

As it tries to locate:

http://localhost:3000/node_modules/@angular/router/bundles/router.umd.js

Which leads to the error:

Error: GET http://localhost:3000/node_modules/@angular/router/bundles/router.umd.js 404 (Not Found)

There seems to be no /bundle/router.umd.js

The reason Angular is looking for this specific file is because of:

var ngPackageNames = [
    'common',
    'compiler',
    'core',
    'forms',
    'http',
    'platform-browser',
    'platform-browser-dynamic',
    'router',
    'router-deprecated',
    'upgrade',
];

// Bundled (~40 requests):
    function packUmd(pkgName) {
        packages['@angular/'+pkgName] = { main: 'bundles/' + pkgName + '.umd.js', defaultExtension: 'js' };
    }

Here is the content of package.json:

...
  "dependencies": {
  "@angular/common":  "2.0.0-rc.3",
  "@angular/compiler":  "2.0.0-rc.3",
  "@angular/core":  "2.0.0-rc.3",
  "@angular/forms": "0.1.1",
  "@angular/http":  "2.0.0-rc.3",
  "@angular/platform-browser":  "2.0.0-rc.3",
  "@angular/platform-browser-dynamic":  "2.0.0-rc.3",
  "@angular/router":  "3.0.0-alpha.7",
...

Attempting to update the package using npm install @angular/router results in the following error:

├── UNMET PEER DEPENDENCY @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ea8985988faad8c4dac4dac79889c4d9">[email protected]</a>
├── UNMET PEER DEPENDENCY @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d4559595d6d1f031d031d005f4e031e">[email protected]</a>
└── @angular/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="097b667c7d6c7b493a27392739246865796168273e">[email protected]</a>

It's apparent that Angular2 is still in Beta. Any guidance on this issue would be greatly appreciated.

Answer №1

It's likely that the package will undergo changes as it's still in the alpha stage. In the meantime, you can remove it from the ngPackageNames object and load it into the packages object using the following:

'@angular/router': { main: 'index.js', defaultExtension: 'js' }

It doesn't seem to follow the pattern of the other modules just yet.

For reference, here's an example I experimented with that seems to correctly handle the router: Gist

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error caused by properties of a variable derived from an interface in the compiler

I'm confused as to why the compiler is saying that the properties "name" and "surname" don't exist on type "ITest1" within function test1. It's a bit unclear to me: interface ITest1{ name: string; surname: string; age: number; } ...

Error: Unable to execute NGRX selector - x is not a valid function

I'm puzzled as to why I keep encountering a TypeError with this code. Is there something obvious that I'm overlooking? export const selectAllUsers = createFeatureSelector<ReadonlyArray<User>>('users'); export const select ...

Challenges with implementing asynchronous functions in NestJS controllers

Currently, I am in the process of developing a finance tracker application that involves importing data from a CSV file. The import functionality checks if an entry already exists in the database, adds a specific category to it if not found, and then saves ...

Angular directive for converting fields to title case

I have created a custom directive to transform all table column data into titlecase. The directive I implemented is designed to achieve this transformation, keeping in mind that pipes are not being counted: @Directive({ selector: '[appTitleCase]' ...

Transmit a form containing a downloaded file through an HTTP request

I am facing an issue with sending an email form and an input file to my server. Despite no errors in the console, I can't seem to upload the file correctly as an attachment in the email. post(f: NgForm) { const email = f.value; const headers = ...

Setting up webpack to compile just the necessary assets for running an Angular 5 application

I am currently using Angular 5 and I encountered a situation when running the following command: ng build --prod --named-chunks --aot This command generated numerous files and folders in the 'dist' directory: [development a85a7dc] Initial dist ...

The "if(x in obj)" statement in Typescript does not properly narrow down my custom Record

I am struggling with a code snippet where I am trying to check if a string exists in my custom record using the if(x in obj) guard statement, but it seems to not be working as expected. Below is the sample code snippet that is throwing an error: type Ans ...

What steps can be taken to troubleshoot the npm start problem?

I am encountering the error shown below: https://i.stack.imgur.com/jqmcF.png This issue is present on Windows but not on Linux. Which dependency do I need to install? I can't seem to locate the Color npm dependency. ...

The symbol "/" is not a valid command recognized by the system

Today, I'm working on developing a set of npm packages and tasks that require repetitive preparation. To streamline the process, I decided to create a CLI tool for quick execution of these tasks. Below is the snippet from src/cli.js: export function ...

Utilizing a TypeScript Variable as a Tagname in an HTML File within Angular

This specific problem is originally documented in this post. Despite being flagged as a duplicate, my scenario differs because the HTML content at hand is too extensive for utilizing innerHTML. The structure of my component's HTML file is as follows: ...

The Microsoft EDGE browser is encountering a XHR HTTP404 error when trying to access a TypeScript

While debugging a Typescript web application in Visual Studio 2015 and using the Microsoft EDGE browser, an error is reported as follows: HTTP404: NOT FOUND - The server cannot locate anything that matches the requested URI (Uniform Resource Identifier). ...

Upon refreshing the Angular application in the browser, we received a response from Django

I am currently developing an application with a Django backend and an Angular frontend. Everything was working smoothly until I encountered an issue after refreshing a page in the browser. The Angular response stopped coming through, but I continued to rec ...

Each time new scripts are loaded, the Angular 13 window.ng.ɵcompilerFacade gets swapped out for a fresh

New Update: After observing the behavior of loading components/modules in my application, I have noticed a conflict arising between window.ng.ɵcompilerFacade and v13 compliance format when switching between Angular versions. The issue occurs when loading ...

Having issues with Angular 2/4 unable to read an object within the initForm() function

In the process of creating an edit form using Angular, I am facing a problem with understanding the lifecycle of the object retrieved from my backend server. After making a call to my service in ngOnInit(), I receive valid data. However, when I assign this ...

Issue: Module 'stylelint' not found in Angular Project

I've been attempting to execute this command to validate all of the .scss files (and even tried with .css files) and I keep encountering this error. $ stylelint "apps/**/*.scss" It worked once before but not anymore, even after restarting my compute ...

Executing an Angular 4 script using a scheduled CRON job

We are currently facing a challenge with our Angular-built APP for Android phones. The logic has become quite intricate and we have decided to transfer it to our server, where it can be executed as a CRON job every hour instead of within the Phone APP it ...

Problem with Angular Slider

I'm in the process of creating a carousel component in Angular, but I'm facing an issue where the carousel is not appearing as it should. Below is the code for my carousel component. carousel.component.html: <div class="carousel"> ...

I'm really puzzled as to why they would choose to export in this manner in React

I noticed that several files were exported in a similar manner, and I'm unsure why this specific method was chosen. Could there be any advantages or particular reasons for exporting them like this? index.ts export { default } from './Something& ...

Automatically assigning IDs to all elements on an Angular webpage

We are currently developing an enterprise web application and have brought on board an e2e test engineer to automate tests. The test engineer has requested that we assign IDs to all elements in our pages. Is there a tool or method available to automatical ...

Having trouble with the backbutton override in Angular 7 and Cordova 8?

I'm creating a mobile app using Angular 7 and Cordova 8. I need to prevent the default behavior of the back button in order to stop the app from closing. Following instructions in the Cordova documentation, I added an event listener to override the ba ...