Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught ReferenceError: DS is not defined #3219

Closed
jrm2k6 opened this issue Jun 5, 2015 · 24 comments
Closed

Uncaught ReferenceError: DS is not defined #3219

jrm2k6 opened this issue Jun 5, 2015 · 24 comments

Comments

@jrm2k6
Copy link

jrm2k6 commented Jun 5, 2015

npm ember-data 1.0.0-beta.19
bower ember-data 1.0.0-beta.18
ember-cli 0.2.7
ember 1.12.0

import Ember from 'ember';
import DS from 'ember-data';

export default Ember.Route.extend({
});

Error: Uncaught ReferenceError: DS is not defined

I tried to uninstall/reinstall the bower and npm packages. What should I try now?

@fivetanley
Copy link
Member

try setting it to beta.19 in your bower.json?

@fivetanley
Copy link
Member

window.DS seems to get defined in globals mode so I'm a bit confused here, as the addon should just load that.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 5, 2015

I was going to try that either have both a 18 or 19. Why are they different though? The bower package hasn't been updated?

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 5, 2015

window.DS is undefined.
Switching both to 19 or 18 doesn't change a thing.

@fivetanley
Copy link
Member

Bower should be updated.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 5, 2015

This is what the bower installation shows though

https://gist.github.com/jrm2k6/b3292b624ea33ebd23cd

Something interesting in there? I chose the second option both time.

@fivetanley
Copy link
Member

Does changing both package.json and bower.json to beta.18 make a difference?

also running npm cache clean && bower cache clean && npm i && bower i after changing versions.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 5, 2015

I tried already both 18. Will try again. But it didn't make a difference

EDIT: still the same.

@fivetanley
Copy link
Member

Are you sure you're not getting any other errors in your DevTools console?

@fivetanley
Copy link
Member

Also if the stack is available for your current error that would be great as well.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 5, 2015

DevTools:
screen shot 2015-06-05 at 4 19 52 pm

Stack:
screen shot 2015-06-05 at 4 20 47 pm

Just removing the import DS from 'ember-data' works, on the error/warnings are not changing in the dev tools.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 5, 2015

I just generate a new project, and it seems to be working with beta-18/beta-19 for both. I don't know why it doesn't work in my other project though. It could be because in my other project (which is basically a laravel project, the initialization of the project got messed up for some reason)?
It could be related (wild guess!) to ember-cli/ember-cli#4213

I am also wondering why it asked me to chose a version of ember/ember-data

Unable to find a suitable version for ember, please choose one:
    1) ember#~1.0.0 which resolved to 1.0.1 and is required by ember-data#0.0.14
    2) ember#1.12.0 which resolved to 1.12.0 and is required by signup-frontend
    3) ember#>= 1.8.1 < 2.0.0 which resolved to 1.12.0 and is required by ember-data#1.0.0-beta.19
    4) ember#> 1.5.0-beta.3 which resolved to 1.12.1 and is required by ember-resolver#0.1.15
    5) ember#>=1.4 <2 which resolved to 1.12.1 and is required by ember-cli-shims#0.0.3

Prefix the choice with ! to persist it to bower.json

? Answer: !2
bower ember                          resolution Saved ember#1.12.0 as resolution

Unable to find a suitable version for ember-data, please choose one:
    1) ember-data#~0.0.14 which resolved to 0.0.14
    2) ember-data#1.0.0-beta.19 which resolved to 1.0.0-beta.19 and is required by signup-frontend

Prefix the choice with ! to persist it to bower.json

? Answer: 2!
bower ember-data                     resolution Saved ember-data#1.0.0-beta.19 as resolution
bower ember-data#1.0.0-beta.19          install ember-data#1.0.0-beta.19

Still no luck in my current project, which is REALLY frustrating.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 8, 2015

Moving the ember app out of the laravel project doesn't change a thing. Trying to experiment to see if another package could cause this?

Creating a new ember app from scratch and requiring ember-data does work.

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 8, 2015

The issue is with this package https://github.com/unionups/ember-cli-bootstrap-sass. Removing it works and DS is required correctly.

@jrm2k6 jrm2k6 closed this as completed Jun 8, 2015
@Intelliarts
Copy link

I don't use ember-cli-bootstrap-sass, but have the same issue.

model:

`import DS from 'ember-data'`

User = DS.Model.extend {
  email: DS.attr('string')
}

`export default User`

route:

`import User from 'frontend/models/user'`

In console: ReferenceError: DS is not defined in vendor.js:57300:4

code in vendor.js:

define('ember-data', [], function() {
  "use strict";

  return {
    'default': DS
  };
});
})();

Error caught in 'default': DS line

Any thoughts?

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 14, 2015

Are you using some specific package? U would try to run the node REPL and
import ember data, and check if DS is defined. If if works I would remove
my npm package one by one to see if one is problematic.
On Jun 14, 2015 2:18 PM, "Intelliarts" notifications@github.com wrote:

I don't use ember-cli-bootstrap-sass, but have the same issue.

model:

import DS from 'ember-data'
User = DS.Model.extend {
email: DS.attr('string')
}
export default User

route:

import User from 'frontend/models/user'

In console: ReferenceError: DS is not defined in vendor.js:57300:4

code in vendor.js:

define('ember-data', [], function() {
"use strict";

return {
'default': DS
};
});
})();

Error caught in 'default': DS line

Any thoughts?


Reply to this email directly or view it on GitHub
#3219 (comment).

@mattma
Copy link

mattma commented Jun 16, 2015

I have run into the same issue here.

I am using "Ember@2.0.0-beta.1" and "Ember-cli@0.2.7"

When I have ember-data@1.0.0-beta.18 in bower.json and package.json as dependency, I run into the problem below:

Uncaught TypeError: Cannot read property 'indexOf' of undefined(anonymous function) @ adapter.js:486(anonymous function) @ main.js:131
app-shims.js:15Uncaught ReferenceError: DS is not defined

When I have ember-data@1.0.0-beta.19.2 in bower.json and package.json as dependency, I run into the problem below:

Uncaught TypeError: Cannot read property 'indexOf' of undefined(anonymous function) @ fixture-adapter.js:10(anonymous function) @ main.js:130
app-shims.js:15Uncaught ReferenceError: DS is not defined

Different errors on different version. Trying to remove one package at the time is not ideal since app requires most of them. I have to remove the related code to avoid other errors as well. Any thoughts?

@jrm2k6
Copy link
Author

jrm2k6 commented Jun 16, 2015

@mattma I agree that removing one package at a time is annoying. What I would do in your case, to rule-out an issue caused by another package is to create a new project, and add the same package as you have one by one. That is my only idea so far.

@mattma
Copy link

mattma commented Jun 16, 2015

@jrm2k6 @fivetanley

After play around for an hour, I think the issue is coming from "Ember" core. There is nothing broken or need-to-be-fixed in Ember-data side. Or any other npm modules or ember-cli dependencies.

simply switch to a different version of Ember-core in "bower.json", then run 'bower install'. You should have a working app.

Then switch back to a latest "Ember@2.0.0-beta.1". run "bower install". Now you should have a latest greatest working app with latest "Ember-data@1.0.0-beta.19.2".

I believe when running "bower install", the dependencies order have been messed up.

Confirmed that "Ember@2.0.0-beta.1+bc58a125" and "Ember@2.0.0-beta.1+169a5d2aed" works fine.

Got this "bower install" message, due to the versioning issue. I believe it is the thing of 2.0.0. DS resolved to a different version cause the breakage

Please note that,
   XXX depends on ember#beta which resolved to ember#169a5d2aed
    ember-resolver#0.1.17 depends on ember#> 1.5.0-beta.3 which resolved to ember#1.13.0
    ember-cli-shims#0.0.3 depends on ember#>=1.4 <2 which resolved to ember#1.13.0
    ember-simple-auth#0.8.0-beta.3 depends on ember#>=1.2 which resolved to ember#1.13.0
    ember-data#1.0.0-beta.19.2 depends on ember#>= 1.8.1 < 2.0.0 which resolved to ember#1.13.0
Resort to using ember#beta which resolved to ember#169a5d2aed
Code incompatibilities may occur.

@bmac
Copy link
Member

bmac commented Jun 16, 2015

@mattma Is correct. Ember Data does not currently work with Ember 2.0 beta. Ember has removed some deprecated IE8 support code in the Ember 2.0 branch that Ember Data was relying on for IE8 support.

In the next few days there will be an Ember Data 2.0 beta release that is compatible with the current Ember 2.0 beta.

@mattma
Copy link

mattma commented Jun 17, 2015

@bmac Thank you for the confirmation. I cannot wait to use Ember Data 2.0 beta release. Mainly because I am on the alpha wagon and ready for the latest 2.0 one way binding goodness. Is there an ETA on the release date?

@visoft
Copy link

visoft commented Jul 2, 2015

I'm getting the same problem with Ember 1.13.2 + Ember Data beta 1.0.0-beta19.1. I can't upgrade Ember Data yet because I'm blocked by this bug.

@bmac
Copy link
Member

bmac commented Jul 2, 2015

@visoft. Is there another error on the page before the "DS is not defined"?

@visoft
Copy link

visoft commented Jul 2, 2015

Nope, just that error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants