The functionality of provideRouter and RouterConfig cannot be located in the updated @angular/router version 3.0.0-alpha.3^

Currently in the process of migrating an angular2 app to RC2 and experimenting with the router's version 3 alpha.

Followed the setup provided by the angular docs for routing as demonstrated in the plunker. However, encountering the following errors:

'/@angular/router/index"' is showing no exported member 'provideRouter'

'/@angular/router/index"' is showing no exported member 'RouterConfig'

These errors occur when trying to use the following imports in my app.router.ts file:

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

It's worth noting that I am using typescript in visual studio with commonjs module format.

Providing the list of dependencies from my packages.json:

"@angular/common": "2.0.0-rc.2",
"@angular/compiler": "2.0.0-rc.2",
"@angular/core": "2.0.0-rc.2",
"@angular/http": "2.0.0-rc.2",
"@angular/platform-browser": "2.0.0-rc.2",
"@angular/platform-browser-dynamic": "2.0.0-rc.2",
"@angular/router": "3.0.0-alpha.3",
"@angular/router-deprecated": "2.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.2",
"systemjs": "0.19.27",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.12"

Even after setting the angular/route to the npm cdn in my system.config.js like so:

'@angular/router': 'https://npmcdn.com/@angular/[email protected]'

The error still persists.

Experimented with using the alpha.4, alpha.5, and the latest alpha.6 version.

Attempting to resolve the issue, I deleted the node_modules folder and reinstalled via npm.

QUERY:

Seeking assistance to understand why the exported members provideRouter and RouterConfig cannot be located.

Thank you!

Answer №1

I encountered a similar issue and was able to resolve it by opting for Version 3.0.0-alpha.7

Below is a snippet from my package.json file:

"dependencies": {
"@angular/common":  "2.0.0-rc.2",
"@angular/compiler":  "2.0.0-rc.2",
"@angular/core":  "2.0.0-rc.2",
"@angular/http":  "2.0.0-rc.2",
"@angular/platform-browser":  "2.0.0-rc.2",
"@angular/platform-browser-dynamic":  "2.0.0-rc.2",
"@angular/router":  "3.0.0-alpha.7",
"@angular/upgrade":  "2.0.0-rc.2",
"systemjs": "0.19.31",
"core-js": "^2.4.0",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.6",
"zone.js": "^0.6.12",
"angular2-in-memory-web-api": "0.0.12",
"bootstrap": "^3.3.6",
"contentful": "3.3.14"}

Although it's worth noting that I don't consider it to be completely stable, and the updated Documentation can be a bit confusing at times. Here's the link for your reference: https://angular.io/docs/ts/latest/guide/router.html

Answer №2

Consider using provideRoutes instead of provideRouter

import {provideRoutes} from "@angular/router";

Here is an example of how you can set up your routing:

provideRoutes([
    {path: '', redirectTo: '/myurl'}
])

UPDATE You no longer need provideRouters. Simply define paths and import Routes from '@angular/router';

import {RouterModule, Routes} from '@angular/router';

const APP_ROUTES: Routes = [
  {path: '', redirectTo: '/something', pathMatch: 'full'},
  {path: 'something', component: SomethingComponent},
  {path: 'something-list', component: SomethingListComponent}
];

export const your_routing = RouterModule.forRoot(APP_ROUTES);

Answer №3

After spending several hours grappling with this issue, I decided to upgrade to beta7. One important point to note is the change in packagenames in system.config.js - for example, "platform-browser-dynamic/platform-browser-dynamic.js" is now referred to as "platform-browser-dynamic/index.js."

Despite the upgrade, I am encountering difficulties setting up a default route. Any suggestions on how to resolve this?

UPDATE: I have found that setting up a default route is as simple as:

{
    path: '',
    redirectTo: 'index.php/component/atkstat/dashboard'
}, 

Answer №4

If you want to enable routing in your Angular application, make sure to include the following line for @angular/router module. Keep in mind that there is currently no UMD support for the router.

packages['@angular/router'] = { main: 'index.js', defaultExtension: 'js' };

Be sure to check the package.json and system.config.js files for additional guidance that may assist you in this process.

http://plnkr.co/edit/y31K7xbiQSVH59qsAOZF?p=preview

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

Loading templates dynamically within ng-repeat is a powerful feature that enhances the flexibility and

I need help loading a template dynamically while using an ng-repeat: <ul> <li ng-repeat="prop in entity" > <div ng-include src="prop.template"></div> </li> </ul> The value of prop.template is the URL of ...

What enables typescript to be eligible for transpiling is its equivalent level of abstraction to javascript?

Transpilation is the act of converting code from one language to another with a similar level of abstraction. Can you point out some distinctive characteristics that indicate TypeScript transpires into JavaScript? ...

The type '{ status: boolean; image: null; price: number; }[]' does not include all the properties required by the 'SelectedCustomImageType' type

While developing my Next.js 14 TypeScript application, I encountered the following error: Error in type checking: Type '{ status: boolean; image: null; price: number; }[]' is missing the properties 'status', 'image', and &apos ...

Guide on transferring object between two $states using ui-router

Visit this link for more information Expected Behavior Upon logging in, selecting a Ticker button is expected to trigger the display of matching Tags for that specific Ticker. Actual Results However, upon clicking a Ticker button after logging in, the ...

What steps should be taken to upgrade a ReactJS project to utilize Node.js version 18.12.0 and npm version 8.19.2

Having recently updated my Node.js version to 18.12.0, I encountered some errors when trying to run my React.js project with the command npm start. The errors displayed were: Compiled with problems:X ERROR in ./src/assets/images/arrow_vector.svg Module ...

Exploring the world of Angular CLI testing and the versatility of

Struggling with integrating Angular CLI's test framework and enum types? When creating an enum like the following (found in someenum.ts): const enum SomeEnum { Val0, Val1 } Utilizing it in this way (in app.component.ts): private someEnum = Some ...

Tips on extracting the value from a nested array in JavaScript

If my array is structured like this: $scope.test = [ ["Invalid Image","file size is invalid"], [], [], [], [] ] Is there a way to extract and display only the values from th ...

Using Google App Engine with Python as the back end and AngularJS as the front end is a powerful combination

I am currently working on establishing end-to-end data sharing between GAE using Python and an AngularJS mobile app. The communication is done through JSON as the request body from the mobile app with a contentType set to application/json. Upon checking my ...

Issue: Unable to establish connection to [localhost:27017] while executing MEAN application on HEROKU

I'm currently working on my second MEAN app project. The first one was built manually without using the MEAN stack, which led to some challenges when trying to host it on HEROKU. I initially tried using MONGOOSE but faced difficulties connecting to th ...

Discover the final index of an array with Angular's ng-repeat functionality

I'm currently working with an Object that contains array values which I am trying to iterate over. Here's a simplified example of what I have: $scope.messages = { "1": [ { "content": "Hello" }, { "content": "How are you" }, { "conte ...

AngularJS: The creation of a unique custom filter in Angular causing an infinite loop issue

I have implemented a custom filter called 'partition' in my filter.js file within my Ionic application. However, when I attempt to use it in the template, I encounter a $rootScope error: Error: [$rootScope:infdig] http://errors.angularjs.org/1.2 ...

Ensure proper GET request is made

I can't seem to figure out the correct way to make a GET request in Angular to fetch a String from a Java API, or maybe I'm not calling the get function properly within the .subscribe() method. Here's my service.ts with the issue in the busc ...

Incorporate an additional retrieve functionality in your asp.net web api

I'm brand new to the world of asp.net web api. I have a solid understanding of get(), put(), post() and delete(). For my application, I need to implement two additional get() methods. Here is an overview- public class StudentController : ApiControll ...

Struggling to grasp the error: "NDEFReader is not defined" in a Vue3 web application

In the process of developing a vue3 application, I am integrating the NFC Web API to facilitate reading and writing NFC Chips. My project utilizes typescript, vue routing, and pinia for smooth functionality. Everything runs smoothly when the application i ...

A guide on converting JSON to TypeScript objects while including calculated properties

I have a standard JSON service that returns data in a specific format. An example of the returned body looks like this: [{ x: 3, y: 5 }] I am looking to convert this data into instances of a customized TypeScript class called CustomClass: export class ...

Issues with Ionic 3 Directive Not Functioning

Struggling to create a custom directive in Ionic that won't resize automatically? I can't figure out what's going wrong. Here's the code snippet from my project, which is an Ionic 3 app with Angular 4: import { Directive, HostListener ...

Is subtyping causing issues in TypeScript's inheritance model?

I am currently utilizing TypeScript for my coding projects, and I have observed that it can allow the production of non-type-safe code. Despite implementing all the "strict" options available to me, the behavior I am experiencing goes against the principle ...

Exploring the functionalities of custom modules in AngularJs

Is there a way for me to get started with this particular module over at ? Here's the controller I currently have: app.controller('FormController', function ($scope, localStorageService) { }); I've also injected localStorageService ...

Docker container has successfully installed Node, however, npm is missing

I am encountering an issue with my DockerFile. Here is the relevant section: FROM docker:17.12.0-ce as static-docker-source FROM ubuntu:18.04 FROM python:3.8-slim-buster ARG CLOUD_SDK_VERSION=335.0.0 ENV CLOUD_SDK_VERSION=$CLOUD_SDK_VERSION ENV PATH &quo ...

Error: Node.js encountered an unexpected illegal token

https://i.sstatic.net/Ozzo8.jpg Attempting to use the command cd to switch directories to C:\xampp\htdocs\project. Encountering problems with node.js command prompt. ...