Reputation: 4045
I had this same problem with aurelia-api and aurelia-authorisation in that I cannot seem to add these plugins without it not being recognised. In my login.ts file I have added:
import {ValidationRules, ValidationController} from "aurelia-validation";
...and its telling me it cannot find module aurelia-validation.
I recently asked THIS question and then followed the comment suggestion but still to no avail.
Had a look for similar questions but the one I did find was out of date.
This is what I have done.
Added "aurelia-validation" as a plugin in the boot.ts file as follows:
import "isomorphic-fetch";
import { Aurelia, PLATFORM } from "aurelia-framework";
import { HttpClient } from "aurelia-fetch-client";
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap";
declare const IS_DEV_BUILD: boolean; // The value is supplied by Webpack during the build
export function configure(aurelia: Aurelia) {
aurelia.use
.standardConfiguration()
.plugin(PLATFORM.moduleName("aurelia-validation")); // Here!
if (IS_DEV_BUILD) {
aurelia.use.developmentLogging();
}
new HttpClient().configure(config => {
const baseUrl = document.getElementsByTagName("base")[0].href;
config.withBaseUrl(baseUrl);
});
aurelia
.start()
.then(() => aurelia.setRoot(PLATFORM.moduleName("app/app/app")));
As you can see I have used:
.plugin(PLATFORM.moduleName("aurelia-validation"));
This was after adding "aurelia-validation" to the package.json file and then running yarn.
Do I also need to add this to webpack?
How do you add these plugins?
Upvotes: 0
Views: 201
Reputation: 1
You may need to download npm install aurelia validation --save,and save it in the same folder or path of your project,if u are using IDE for your development check if it has a terminal or console, then type :npm install aurelia validation --save, i had a similar issue and this is how i reoslved it, good luck
Upvotes: 0
Reputation: 111
Depending on how your webpack is configured, you probably just need to add this to the vendor section of your webpack.config.vendor.js file as well, something like this:
module.exports = ({ prod } = {}) => {
...
return [{
...,
entry: {
vendor: [
...
'aurelia-validation',
...
],
},
...
}]
};
And then compile the vendor.js file as well if that is not done automatically in your build process using something like this:
node node_modules/webpack/bin/webpack.js --config webpack.config.vendor.js
Upvotes: 0