How to replace the handlebars with htmlbars in Ember CLI app? - ember.js

I am facing the following issue after upgrading the Ember and Ember data to the canary versions.
Cannot set property 'compilerInfo' of undefined
I found the discussion about the issue in Ember CLI repo.
https://github.com/ember-cli/ember-cli/issues/2955
The solution is to replace handlebars with htmlbars. But I don't know the exact steps to do that.
I checked handlebars repo. It gives code snippets but I don't know where to place the code exactly.
Any idea?

You will still be using Handlebars, but you need 2.0.
For HTMLBars, what you'll change is the template compiler.
npm uninstall --save-dev broccoli-ember-hbs-template-compiler
npm install --save-dev ember-cli-htmlbars
rm -rf bower_components
bower install --save handlebars#2.0.0
bower install

Related

Why should I use ember install over NPM or yarn?

I'm new to ember and I discover the command ember install pkg and I'm wondering why such package instead of using external package manager such as yarn or npm which are industry-wide/de-facto standard.
Question
Why should I use ember install over NPM or yarn?
ember install addon-name is a short hand for npm install --save-dev addon-name && ember g addon-name
The documentation provides the answer for this one (ctrl + f ember install):
Installs the given addon into your project and saves it to the
package.json file. If provided, the command will run the addon’s
default blueprint.
The release notes for version 0.1.5 provide a clue for this as well:
#2805 Added the install:addon command, which installs an addon with NPM and then runs the included generator of the same name if it
provides one.
So, ember install is just a replacement for npm in most cases but when a blueprint is provided it will run those as well.

Ember 2.7.2 and ember-models-table: A helper named "models-table" could not be found

I install Ember 2.7.2 and I create my first application. I install the addon ember-models-table (ember install ember-models-table).
Template:
<h3>Prueba</h3>
{{models-table
data=model
columns=columns}}
I use "ember server" to test my app. When I go to http://localhost:4200/prueba I see this error in console:
Uncaught Error: Assertion Failed: A helper named "models-table" could not be found
Any idea of what is wrong?
Maybe you didn't install this addon correctly for some reason. All I can recommend you is to re-install it by typing these commands:
npm uninstall --save ember-models-table
npm prune
rm -rf node_modules tmp
npm cache clean
npm install
ember install ember-models-table
If the problem still exists after you re-install the addon, probably something is wrong with your environment, not the ember itself.

Ember-cli upgrade broke everything

I had a running Ember program built using Ember-Cli 1.13.12 using Node 4.2.4. I tried to upgrade to Ember-Cli 2.3.0 running on Node 4.2.6. I followed the procedure outlined in: https://github.com/ember-cli/ember-cli/releases. After the upgrade, my program generated all sorts of errors. I spent an entire day trying to get the program to work but couldn't. So I decided to try reverting back to Ember-cli 1.13.12. I checked out the lastest working version of my program before the upgrade attempt using git. I did the following to revert back to Ember-cli 1.13.12:
npm uninstall -g ember-cli
npm cache clean
bower cache clean
npm install -g ember-cli#1.13.12
rm -rf node_modules bower_components dist tmp
npm install
bower install
But the system still doesn't work. 'Ember Server' works as expected. But when I go to localhost:4200 in my browser, I get two errors:
Uncaught Error: Assertion Failed: Ember Views require jQuery between 1.7 and 2.1
Uncaught Error: Could not find module `ember` imported from `tw/app`
Can someone please help me figure out what's going on?
I think you're being hit by the problem in this post.
You can probably fix the issue by upgrading to ember-cli 1.13.14, if not check bellow.
For reference, the fix (if you're not updating ember-cli) is (from this answer by Lawree)
This is a bug due to a new version of jQuery. For now you can change
the following line in your bower.json file. Then run bower install and
it should work.
"jquery": "^1.11.3", to
"jquery": "1.11.3",

Is there a way to remove bower dependencies using ember-cli

I installed a bower dependency using ember-cli as follows:
ember install:bower utf8
Is there an equivalent way to uninstall the same dependency?
So far I have resorted to:
bower uninstall utf8
And then manually edited the bower.json file. Is there a more correct way to do this? Or are there any drawbacks of doing it my way?
Yes, there is. You just have to use --save or --save-dev:
$ bower uninstall utf8 --save
When you use --save, then it's uninstalled and removed from dependencies section, and --save-dev removes it from devDependencies.
You can use the same flags with bower install or even npm install/npm uninstall.
EDIT:
Here's a reasoning why they don't want to make an alias for bower uninstall: https://github.com/ember-cli/ember-cli/issues/3163

npm install ember-data just installs index.js file

When I do npm install ember-data --save, I get only the following files:
./node_modules/ember-data/
./node_modules/ember-data//lib
./node_modules/ember-data//lib/ember-addon
./node_modules/ember-data//lib/ember-addon/blueprints
./node_modules/ember-data//lib/ember-addon/blueprints/ember-data
./node_modules/ember-data//lib/ember-addon/blueprints/ember-data/index.js
./node_modules/ember-data//lib/ember-addon/index.js
./node_modules/ember-data//package.json
./node_modules/ember-data//README.md
I was expecting the same files bower installs, such as ember-data.min.js.
My hunch is I need to do npm install from within node_modules/ember-data? If so, why the extra step?
ember-data is meant to be installed with bower with
$ bower install --save ember-data
Installing ember-data with npm will add it as an add-on for ember-cli project. It will include the files from bower_components. you still need the bower version.
ember-cli has built-in support for ember-data.