npm install ember-data just installs index.js file - ember.js

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.

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.

What is the difference between Node Package and Bower Package?

Taking Ember App for example. ember install ember-bootstrap-4 will add node package. But bower install tether --save will add bower package. Both are part of the app. But why one is in bower and one is in npm?
npm and bower are both packages manager in your Ember application but there are some differences in using them:
Bower is only used in front-end. It will download bower package into your Ember project (bower_component folder) and you still have to add it to your app's assets. For example, if you install moment package in bower, you have to add it to your app by going to ember-cli-build.js and add the following line app.import('bower_components/moment/moment.js'); (view more details in Ember Addons and Dependencies)
NPM is used for server packages. It will download packages into node_modules project. Every ember-cli addons is in npm and when you type ember install <addons-name>, ember will look up for ember addon, place your addon's info in package.json and download it in node_modules folder. Then, Ember will load it automatically for you.
bower install - is for including run time dependencies and you need to import it in ember-cli-build.js to use.
npm install - is for including development/build time dependencies.

How to upgrade ember cli version

I upgraded ember-cli to version 2.4.3
npm install -g ember-cli
I can see -- ember-cli#2.4.3 , in the listed dependencies,
but when I check :
(master *)$ ember -v
version: 2.4.2
node: 5.6.0
os: darwin x64
ember cli version is still 2.4.2
what's wrong ?
Updating Ember-CLI's version and ember project's version are different thing.
To update Ember-CLI:
npm uninstall -g ember-cli
npm cache clean
bower cache clean
npm install -g ember-cli#1.13.14
To update your project:
rm -rf node_modules bower_components dist tmp
npm install --save-dev ember-cli#1.13.14
npm install
bower install
ember init
Here is the resource: https://github.com/ember-cli/ember-cli/releases
I strongly recomend you to select which files will be overwritten. You should compare diffs of files. application.hbs, router.js, environment.js, ember-cli-build.js are important files those you don't want them to be overwritten.
UPDATE 2020-02-19:
ember-cli-update
handles updating your project.

How to replace the handlebars with htmlbars in Ember CLI app?

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

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