2
votes

Trying to use ember-validations plugin for ember-cli. Bumped with this issue that I can't figure what is missing.

Here is the dependencies part in my package.json:

"devDependencies": {
    "broccoli-asset-rev": "^2.0.0",
    "broccoli-ember-hbs-template-compiler": "^1.6.1",
    "ember-cli": "0.1.9",
    "ember-cli-6to5": "0.2.1",
    "ember-cli-content-security-policy": "0.3.0",
    "ember-cli-dependency-checker": "0.0.7",
    "ember-cli-ic-ajax": "0.1.1",
    "ember-cli-inject-live-reload": "^1.3.0",
    "ember-cli-qunit": "0.1.2",
    "ember-data": "1.0.0-beta.12",
    "ember-export-application-global": "^1.0.0",
    "express": "^4.8.5",
    "glob": "^4.0.5",
    "ember-validations": "~2.0.0-alpha.2" //Also tried with "~ 2.0.0" as advised in the guide
}

And a simple controller which looks like this:

import Ember from 'ember';
import EmberValidations from 'ember-validations';

export default Ember.Controller.extend(EmberValidations.Mixin, {
    actions: {
        //....
    },
    validations: {
        mailid: {
            presence: true
        },
        password: {
            presence: true
        }
    }
});

And the bower.json:

{
  "name": "ahem",
  "dependencies": {
    "handlebars": "~1.3.0",
    "jquery": "^1.11.1",
    "ember": "1.8.1",
    "ember-data": "1.0.0-beta.12",
    "ember-resolver": "~0.1.11",
    "loader.js": "ember-cli/loader.js#1.0.1",
    "ember-cli-shims": "ember-cli/ember-cli-shims#0.0.3",
    "ember-cli-test-loader": "rwjblue/ember-cli-test-loader#0.0.4",
    "ember-load-initializers": "ember-cli/ember-load-initializers#0.0.2",
    "ember-qunit": "0.1.8",
    "ember-qunit-notifications": "0.0.5",
    "qunit": "~1.17.1",
    "bootstrap": "~3.3.2"
  }
}

But looking the route in the browser gets an error message in the console:

Could not find module ember-validations

Not sure what I'm doing wrong. Any help appreciated.

2
Please run npm list ember-validations in your project directory to find out if ember-validations is installed and what version. - Daniel Kmak
Yep, its installed and I can see this [email protected] - droidbot
Please post your bower.json file. - Daniel Kmak
added it in the post now.. - droidbot
Update: Tried using ember install:npm [email protected] with the hopes that it might add ember-validations to the ember-cli shims. But no luck still. - droidbot

2 Answers

2
votes

The package seems to be looking for a module called ember-easyform-cli. Thus, I suggest adding:

ember-easyform-cli": "git://github.com/kristianmandrup/ember-easyform-cli.git#master" 

to the package.json file.

Also, I noticed that there are 3 targets ["0.0.0","2.0.0-alpha.1","2.0.0-alpha.2"] available. Try using the 2.0.0-alpha.1 version instead of 2.0.0-alpha.2 by adding "ember-validations": "2.0.0-alpha.1" into the package.json.

0
votes

I had the same issue after installing https://github.com/abpetkov/switchery and importing it via brocfile:

app.import('bower_components/switchery/switchery.js');

switching it to the dist version solved it for me

app.import('bower_components/switchery/dist/switchery.js');

It might be possible there's some kind of conflict between ember-validations and other ember modules. Perhaps revise your Brocfile or package.json and find the source of the issue by trial and error or temporarily disable the packages you recently installed.