Install or not ember-cli globally

I wonder if I need to install ember-cli globally before cloning an Ember project

npm install -g ember-cli

or it is enough to have Yarn installed and hit yarn to install the dependencies which include ember-cli?

The global ember-cli always defers to the local version of ember-cli when inside a project. The main nicety of having it installed globally is being able to run ember commands directly.

For yarn users, you can use yarn ember instead, and that works just fine…

Thank you for your response. I need it to know if I have to put the install command in Jenkinsfile. So as far as I understood, I don’t need to install it. Right?

To clear some details, if you don’t have ember installed globally, as @rwjblue said, you won’t be able to run any ember related commands. In this case, having yarn installed, you can run yarn ember to display available commands. So running yarn ember s would replace ember s command. Hope this helps.

2 Likes

Is it possible to not defer to the local version? I tried the following and it still returns the local ember-cli version.

/Users/david/.nvm/versions/node/v10.15.0/bin/ember --version

Basically the reason I want to do this is to take advantage of the generators in 3.15, because an app I am working on is stuck on ember-cli@3.12 due to another addon that has been deprecated. Everything else is Octane, so would be cool to leverage those generators until we can migrate away from that other addon.

@skaterdav85 If I understand you right, running ember -v in the terminal outside of your app location will always return the global version installed:

Screenshot 2020-01-16 at 09.10.18

Running the same after cd-ing to your Ember app will return the version used by your app as it is declared in the app package.json dependencies:

Screenshot 2020-01-16 at 09.10.51

exactly. I want to use the global version for the generators since my app is stuck on the app’s version of ember-cli.

When you generate a new Ember app, il will always use the default Ember version set globally. In my case, it would be 3.15. If you want to upgrade your Ember app dependencies, see EmberMap free video for more details. Hope this helps

@skaterdav85 you’re correct that ember-cli will work pretty hard to make sure you always get the version that is specified in your app’s own package.json. Even if you manually try to run a different version, that version will notice that it’s not the right one and invoke the other one.

Is the problematic addon public? Which one? It’s certainly possible to get into this situation if the addon was using private API, but it should be relatively rare because going from 3.12 to 3.15 is supposed to be fully compatible for all public APIs.

Also, are you sure the addon is incompatible with ember-cli@3.15, or is it really incompatible with ember-source@3.15? If ember-source is the problem, you can upgrade ember-cli by itself and keep ember-source at 3.12.

Also, maybe the addon isn’t really incompatible with 3.15 but it’s incompatible with some optional features that are on by default in 3.15, and you can just choose not to turn those on while upgrading.

Basically I’m asking these questions because a lot of work went into making 3.15 fully compatible, so I’m curious where the blockers are.

Oh, I should point out that if you do this, it might not solve your generators question because IIRC some of the generators come from ember-source now. The same argument also applies in reverse: you can probably upgrade ember-source but not ember-cli.

Thanks for the response @ef4!

I recently discovered that the app I am working on has a custom component blueprint. Once I deleted that, I was able to generate a Glimmer component with ember-cli@3.12, which is great and good for the time being.

However, the app is still stuck on 3.12. The addon that is causing problems is ember-cli-tailwind, which has been deprecated. Unfortunately, our app uses ember-cli-tailwind in the app itself and for an in-repo addon, so removing it (in favor of importing tailwindcss directly) isn’t trivial. We’ll have to remove it at some point though. Basically the issue is that we can’t run ember build -prod with ember-cli@> 3.12. There is actually an issue for this (ember build -prod fails with broccoli-persistent-filter:CleanCSSFilter error · Issue #37 · embermap/ember-cli-tailwind · GitHub), but since the addon is deprecated, it isn’t going to get fixed. The error we get is this:

Based on my research, I think the problem might be coming from this change: Require minify-css preprocessors to be registered externally. · ember-cli/ember-cli-preprocess-registry@5e4dea3 · GitHub

You can also take a look at how @samselikoff explains to migrate off of Ember CLI Tailwind and start working directly with the TailwindCSS npm package in EmberMap video, hope this helps.

That’s good news, because going from ember-cli-tailwind to directly configuring tailwind with postcss is a pretty small change, and it doesn’t depend on the size of your app (the way you write the actual app code / styles doesn’t change.)