Wrong ember data version used by ember cli? - ember.js

I'm trying to roll back to v1.0.0-beta.16 after having used v1.0.0-beta.17.
I uninstalled version .17 and installed version .16, which seems to have worked according to npm:
$ npm list --depth=0
...
├── ember-data#1.0.0-beta.16
...
But when I run ember it still seems to use version .17 according to the Chrome console:
Any ideas?

You should change the version in both package.json and bower.json files. Bower stands for managing your plain JS or CSS assets and ember-data is one of them. On the other hand, npm packages will need ember-data and specify it in your package.json also. Just always remember to change versions of plain JS files in both of them.

Related

Install an NPM package without its optional modules in Ember-CLI

I've got the NPM package xlsx as a dependency in my ember app which comes with an optional module for translations. When I build my app with Ember-CLI I'd like to specify somehow that this optional module be excluded.
The README for that package states “Webpack and browserify builds include optional modules by default. Webpack can be configured to remove support with resolve.alias:”
I'm not sure how I could configure my ember-cli-build.js to work with this.
I do know that I can download the package, build it myself, and then stick the resulting files in my vendor directory but this feels like the wrong way to go about it.
Does anybody have experience with this sort of situation?
Edit
I'm currently including xlsx in my app as a dependency inside my package.json and simply importing it within one of my components.
If you take a look into your node_modules/xlsx/dist/ folder you'll see that there are several different versions of xlsx available: core, full and a third version without a specifier.
You can use either of those versions by putting for example
app.import('node_modules/xlsx/dist/xlsx.core.min.js');
in your ember-cli-build.js file.
Note that the above requires Ember CLI 2.15 or above. If you use an older Ember CLI version you should either upgrade or install xlsx from Bower instead.

How to create a ember version specific project?

When i use,
ember new projname
project is getting created with 2.7.0 ember version. I want to create a older version ember project. What i should use? [i checked options that can be used with new command, but none helps for this.]
Here's what I ended up doing:
create a new directory for my project and cd inside of it
npm init (enter through some bogus details, doesn't matter, we're going to erase soon)
npm install --save-dev ember-cli#desired.version
delete package.json and package-lock.json
ember new app
This got me a node_modules folder with the desired version of ember, and then also allowed me to use the ember cli to generate a project. It will create a folder with the name of the app, of course, and you can safely delete the node_modules folder in the app's parent directory.
This feels like a little bit of a round-about way of doing things, but it worked, and it seemed easier than trying to mess with my global versions.
Hope this helps someone out!
Ember new will create project at the most current version installed on your system.
There are 2 ways around this.
Install an older version of ember-cli globally for the desired version. The benefit would be that you create a new app at the desired version from the get go:
(change #2.11.0 to the desired version from https://github.com/emberjs/ember.js/releases)
npm uninstall -g ember-cli
npm cache clean
npm install -g ember-cli#2.11.0
Keep the current ember-cli version and then downgrade by changing the ember value in package.json :
(this will work for small version changes, not major changes)
you will need to re init your ember app (change 2.11.0 to what you need from https://github.com/emberjs/ember.js/releases)
rm -rf node_modules dist tmp
npm install --save-dev ember-cli#2.11.0
ember init
Node.js is required with every Ember installation and you have to check which version of node is required for the desired version of Ember you want to install. Most likely itll work well with the version currently installed.
you can download the latest (LTS) from: https://nodejs.org/en/
or older versions from: https://nodejs.org/dist/
OSx for example https://nodejs.org/dist/v4.7.0/node-v4.7.0-linux-x64.tar.gz
results

How do I use ember-cli with the LTS release channel?

I would like to update an addon to the long term support release channel using ember-cli. How do I do this?
I know I can put a different version of ember and ember-data in de bower.json and package.json files. But will updates of ember-cli not interfere with these older versions?
Also what is the lts release of ember-data?
The current LTS is 2.4, so you need to open your bower.json and in the ember line, put the following:
"ember": "~2.4.0"
This should install the latest 2.4 at the time of the install.
But will updates of ember-cli not interfere with these older versions?
Ember CLI is mostly decoupled from Ember itself, so it can be used with almost any version. When ember.js is converted into an addon (like what happened with ember-data), you'll need to mind the update instructions for it, so you continue to use the bower package instead of the npm addon.
At the moment Ember Data does not have an LTS.

Uncaught Error: Could not find module `ember-qunit`. Odd out-of-the-box ember-cli behavior

I believe I may have an environment issue here, but I'm quite stuck as to what I can to do resolve it. I created an ember-cli project, committed it to git, added a few things. I ran the typical npm install && bower install commands and tried ember s.
Although the site loads fine, when I browsed to the http://localhost:4200/tests/ to ensure qunit was up and running, I had a few errors.
Uncaught Error: Could not find module `ember-qunit` imported from `ember-project/tests/test-helper
Uncaught Error: Assertion Failed: The tests file was not loaded. Make sure your tests index.html includes "assets/tests.js".
Immediately this raised a red flag, as I have created several ember projects before and not run into similar issues. I had my partners (I'm in school) checkout the project, run the npm install && bower install && ember s and the qunit module worked fine for them!
I've tried to git clone a new repo several times, I've even went so far as to uninstall node and bower completely, but no matter what I try I cannot seem to pull up a normal /tests checkout.
My partners were both running VMs - Ubuntu and Debian, while I'm on a mac, but that seems like it shouldn't be too big of an issue, especially since I created the project!
I've looked several places for this (here, here, and here), but I cannot seem to come to a conclusion which works for me.
I do have an identical bower.json as the rest of my group. I've included the picture below of my file structure, my bower.json, and my tests/index.html.
screenshot
Here are some environment stats:
ember version: 1.13.13
node: 5.0.0
os: darwin x64
bower: 1.7.1
One thing that I did notice is a difference when I do this to see npm's version, but I'm not sure if that matters or not.
ember -v
npm: 2.14.10
npm -v
npm: 3.5.2
It appears to be a regression from the work in ember-cli beta. You can track the progress here https://github.com/ember-cli/ember-cli/issues/5411.
For now, you can add
app.import('bower_components/qunit/qunit/qunit.js');
app.import('bower_components/ember-qunit/ember-qunit.amd.js');
to ember-cli-build.js as a workaround.

How do you import a newly created ember addon?

I'm trying to create my first Ember AddOn and I'm getting stuck importing it into an Ember project. I've created the addon and published to github like this:
ember-cli$ ember addon test-addon
ember-cli$ cd test-addon
ember-cli/test-addon$ git remote add origin <github-url>
Then, from my project, I install the addon:
test-app$ ember install <github-url>
And, lastly, try to import it into a route:
# app/rotues/index.coffee
import TestAddon from 'test-addon'
But, I'm getting this error on the console:
Uncaught Error: Could not find module `test-addon` imported from `test-app/routes/index`
Any ideas where I'm going wrong? I can see the addon in the node_modules directory but not in bower_components. I think(tm) this is my issue but I'm not sure what else I need to do to setup my addon.
tl;dr
cd my-addon
npm link
cd /my/project/dir
npm link my-addon
ember g my-addon # run default blueprint
Then add "my-addon": "*" to the devDependencies section of your app's package.json and restart the ember-cli app server.
Longer Answer
The easiest way to include a locally-developed addon is to use NPM's link
First run npm link from the root of your addon project to register it with npm. Then running npm link <your-addon-name> will have the same effect as npm installing it.
You'll still need to manually add it to your package.json (required for ember-cli to find it when compiling your app) and run the default blueprint (if your addon has one).
If this doesn't seem to be working, check that you've created a package.json in your addon with "ember-addon" in the keywords list (the default ember-cli addon blueprint should do this for you).