1

I'm new to Aurelia, trying to implement some 'simple' dynamic routing with an id.

config.map([
    { route: 'questions/:id', . . .}
    ]);

I receive a runtime error which indicates I'm missing an activate() method.

aurelia-history.js:4 Uncaught (in promise) Error: History must implement activate().
    at mi (aurelia-history.js:4)
    at History.activate (aurelia-history.js:13)
    at AppRouter.activate (aurelia-router.js:1743)
    at aurelia-router.js:1722

I get that there is an activate() missing and it's dropping through to the prototype and throwing this error, I just can't figure out where to add the activate(). I have it in my module, but should I somehow have one in my App class or this history object?

Thanks

-John

JohnKoz
  • 908
  • 11
  • 21
  • [**Do not post images of code or errors!**](https://meta.stackoverflow.com/q/303812/995714) Images and screenshots can be a nice addition to a post, but please make sure the post is still clear and useful without them. If you post images of code or error messages make sure you also copy and paste or type the actual code/message into the post directly. – Rob Sep 23 '18 at 18:45

2 Answers2

2

Ok, for the benefit of other strugglers I tried to retrace my steps and piece together how I solved my problem - the challenge was I changed many variables. But I believe I was able to re-create my error and I broke my application in the same way as before. The error may have started appearing when I upgraded my aurelia-router version from 1.2.1 to 1.6.2.

This was my old package.json:

{
  "name": "ClientWeb",
  "private": true,
  "version": "0.0.0",
  "devDependencies": {
    "@types/webpack-env": "^1.13.0",
    "aspnet-webpack": "^2.0.1",
    "aurelia-bootstrapper": "^2.0.1",
    "aurelia-fetch-client": "^1.0.1",
    "aurelia-framework": "^1.1.0",
    "aurelia-loader-webpack": "^2.0.0",
    "aurelia-pal": "^1.3.0",
    "aurelia-router": "^1.2.1",
    "aurelia-webpack-plugin": "^2.0.0-rc.2",
    "bootstrap": "^3.3.7",
    "css-loader": "^0.28.0",
    "extract-text-webpack-plugin": "^2.1.0",
    "file-loader": "^0.11.1",
    "html-loader": "^0.4.5",
    "isomorphic-fetch": "^2.2.1",
    "jquery": "^3.2.1",
    "json-loader": "^0.5.4",
    "style-loader": "^0.16.1",
    "ts-loader": "^2.0.3",
    "typescript": "^2.2.2",
    "url-loader": "^0.5.8",
    "webpack": "^2.3.3",
    "webpack-hot-middleware": "^2.18.0"
  },
  "dependencies": {
    "@types/vis": "^4.21.7",
    "vis": "^4.21.0"
  }
}

At the time I was upgrading several libraries to the latest versions, but I tried reverting back to this original package.json and just updated the aurelia-router version - it generates the original error.

Hope this helps someone.

-John

JohnKoz
  • 908
  • 11
  • 21
1

The reason you have this issue is because you didn't include aurelia-history-browser in your plugins via: aurelia.use.history() or aurelia.use.standardConfiguration().

The aurelia-history-browser module implements the aurelia-history abstract class History, which is a wrapper around native History of browser. The abstract class History basically throw an error with the method name when you call it, like the error you saw.

bigopon
  • 1,924
  • 2
  • 14
  • 23
  • 1
    This is good guidance and I hope it helps others. For my issue I think I had some trouble with WebPack and node_modules. I quickly got into update hell and ended up deleting my node_modules and updating to the latest modules and reinstalling. It's working now, I already had the standardConfiguration() method. Thanks very much! – JohnKoz Oct 04 '18 at 00:29
  • 1
    @bigopen - I'm thankful you took the time to respond, but I struggle with marking it accepted because it does not meet the stated guidance: "Click to accept this answer because it solved your problem or was the most helpful in finding your solution..." This was not my issue and the guidance didn't help me resolve my issue, but it is indeed a good response that others may find valuable. – JohnKoz Oct 04 '18 at 12:21
  • I see, the solution to your issue should be a combination of my answer, and what you did. It'd be nice if you could answer it yourself and mark it as accepted, as it will help future folks – bigopon Oct 04 '18 at 13:11