angular-eclipse icon indicating copy to clipboard operation
angular-eclipse copied to clipboard

ng command not recognized in eclipse preference

Open sayantansinha opened this issue 8 years ago • 43 comments

After I add my angular-cli path on the Javascript->Typescript->Angular-CLI option under Eclipse Preference I get an error saying "The '/node_modules//bin/ng' is not a ng file". I am currently using macOS Sierra (v10.12.6) and using the same ng --version command provides the correct output listing down the version. I got this ng file after running npm install on my project's package.json which is referring to v1.0.2 Any help would be really appreciated.

sayantansinha avatar Aug 12 '17 06:08 sayantansinha

After I add my angular-cli path on the Javascript->Typescript->Angular-CLI option under Eclipse Preference

I'm not sure, but I think this preference is not used with Angular Eclipse 1.3.0 since you can install ng cli in your wizard when you create a cli project. Hav you tried to create an new project with the wizard?

@Springrbua could you see if Javascript->Typescript->Angular-CLI option is used? If not perhaps we should update the wizard?

angelozerr avatar Aug 12 '17 11:08 angelozerr

Let me give more background, I created this project using v1.2.0 and on a windows 7 os. Now, I am hust trying to use the same projecton a mac and I setup the ltes v1.3.0 of the plugin. I was not aware that this preference was not used anymore. So why is it there in the first place? If it is not used then how does the terminal recognizes the ng command? To further note, this is a company issued mac so I do not have admin privileges (going back to my previous issue where I highlighted the same problem for which the execute ng with file option was added by you), as a result of which I am not able to install ng globally as well. So, I am not trying to create a new project, I am trying to access an existing project and just trying to run it after setting it up.

sayantansinha avatar Aug 12 '17 18:08 sayantansinha

@angelozerr The preferences are still in use. Actually the new wizard also just updates this preferences with the options you set.

@sayantansinha The field where you enter the ng location should already provide a default option, if you click on the little arrow on the left. This default option uses the $Project variable and links to the project specific ng installation.
This value used to work for me, so you could try that.

EDIT:
The global preferences are not used if you create a new project, as it always creates project specifc settings. If instead you import a project it will probably use the global settings.

probert94 avatar Aug 12 '17 19:08 probert94

@Springrbua yes I tried that as well and it does not work on either of the platforms (windows or mac) for me. The preferences page shows an error on the top and does not allow me to got another preference popping a message saying this page has invalid options set.

sayantansinha avatar Aug 12 '17 19:08 sayantansinha

Finally it worked, I followed @Springrbua suggestion:

EDIT: The global preferences are not used if you create a new project, as it always creates project specifc settings. If instead you import a project it will probably use the global settings.

I just turned on the project specific settings wherein the default worked

${project_loc:node_modules/.bin}

Also, had to make sure to delete any existing run configurations for the same project as changing the preferences and then running with the same run configuration did not pick up the latest preference (@Springrbua - shouldn't this be something that need to be fixed?)

Hope this might be helpful for someone in the future.

sayantansinha avatar Aug 12 '17 23:08 sayantansinha

Thanks for the feedback!
Probably the global preferences shouldn't validate ng installation, since it is possible to use project variables, which only exist in projects. @angelozerr what do you think about that?

I have to take a look at the problem with the run configurations, I never had this bug but I'll try to reproduce it.
Thanks for your patience and your detailed feedback :)

probert94 avatar Aug 13 '17 08:08 probert94

@angelozerr what do you think about that?

@Springrbua I'm very busy for the moment with Codelens, if you have time please try it and give me feedback, thanks!

angelozerr avatar Aug 13 '17 10:08 angelozerr

@angelozerr I'll take a look at it as soon as possible

probert94 avatar Aug 14 '17 06:08 probert94

Probably the global preferences shouldn't validate ng installation, since it is possible to use project variables

If I remember I had done that, to configure ng path for the whole project of the workspace (it's a kind of ng global installation). But if it's confusing, perhaps we should remove this preferences since now ng new project wizard gives the capability to use ng global installed angular-cli or a given angular-cli to install?

@angelozerr I'll take a look at it as soon as possible

Thanks!

angelozerr avatar Aug 14 '17 06:08 angelozerr

So you would remove the global settings? Or should I just add a "use global settings" option to the wizard and validate it only there?

probert94 avatar Aug 14 '17 08:08 probert94

Or should I just add a "use global settings" option to the wizard and validate it only there?

Yes it was my idea, but if it's more complex to understand, perhaps we should remove this preferences, I don't know.

angelozerr avatar Aug 14 '17 08:08 angelozerr

I guess we should keep the global preferences, because one could use a "global" cli-installation which is installed in some custom folder. This is currently not possible with the Wizard, since it lets you only choose global installation (installed with npm install -g) or install project specific cli.
But I'll take a look at it to see whats better.

probert94 avatar Aug 14 '17 08:08 probert94

I guess we should keep the global preferences, because one could use a "global" cli-installation which is installed in some custom folder.

Exactly, it was my idea.

This is currently not possible with the Wizard, since it lets you only choose global installation (installed with npm install -g) or install project specific cli.

Yes it's the problem. We should add it in the wizard or remove it from General / Preferences.

But I'll take a look at it to see whats better.

Thanks!

angelozerr avatar Aug 14 '17 08:08 angelozerr

Adding my 2 cents, I never use the global settings as my project specific angular-cli installation is what I prefer to use as that is what is going to be used for my eventual building of the final artifacts.

Additionally, I think you guys also need to look into the fact that why the existing run configurations doesn't get updated with the latest changes I do to the preferences wizard. It always refers to the old one and you have to delete and reconfigure the run settings again to allow it to pick up the latest preferences.

sayantansinha avatar Aug 14 '17 17:08 sayantansinha

@sayantansinha Yea of course, I'll also take a look at that. I'll try to reproduce the issue and I'll probably open a new Issue for it.
Thanks again for your feedback!

probert94 avatar Aug 15 '17 13:08 probert94

@angelozerr My idea is to remove "use global CLI" and add "use global preferences" instead.
So to use global cli, you simply need to select it in the global preferences. If you instead want to use a custom, non-global CLI, you can select that in the global preferences.
The Project-Wizard then validates this CLI-installation.
What do you think about that?

probert94 avatar Aug 30 '17 06:08 probert94

Yes it's a good idea.

angelozerr avatar Aug 30 '17 16:08 angelozerr

I have the following error in Eclipse --> "The 'C:/Users/.../AppData/Roaming/npm/ng.cmd' is not a ng file." I am not sure but I believe that it is related to the same issue. I have attached screenshots of the same which might help you understand the issue better. Is there a fix for this? capture2 capture3 capture

nitinkaveriappa avatar Feb 21 '18 20:02 nitinkaveriappa

@nitinkaveriappa Try setting it through project preferences and check. I got it working by changing it on the project preference.

sayantansinha avatar Feb 22 '18 00:02 sayantansinha

Perhaps it's again a bug with new Angular CLI version. Which version of Angular CLI are you using @nitinkaveriappa ?

angelozerr avatar Feb 22 '18 08:02 angelozerr

@sayantansinha I am not able to create an Angular Project, nor am I able to change it in the Preference @angelozerr I am using Angular Eclipse version 1.3.0

nitinkaveriappa avatar Feb 22 '18 17:02 nitinkaveriappa

@angelozerr I am using version 1.3.0

Are you sure it's the version Angular CLI. I think you are using last version of Angular CLI (1.5?)

I think you are using angular-eclipse 1.30, please install 1.4.0-SNAPSHOT with update site.

angelozerr avatar Feb 22 '18 17:02 angelozerr

@angelozerr Sorry my mistake. Angular CLI version I am using is 1.7.0

nitinkaveriappa avatar Feb 22 '18 18:02 nitinkaveriappa

@angelozerr Sorry my mistake. Angular CLI version I am using is 1.7.0

Ok thanks, I think 1.7.0 have changed their "ng -version". I will see that when I will find time.

angelozerr avatar Feb 22 '18 18:02 angelozerr

@angelozerr is there any solution for @nitinkaveriappa problem yet?

manhbui21 avatar May 05 '18 12:05 manhbui21

I must just find time to study and fix the problem. But any contribution are welcome!

angelozerr avatar May 05 '18 17:05 angelozerr

Dear @angelozerr, shouldn't you take the plugin from the Eclipse Marketplace as long as this issue is not fixed?

As far as I can see it, this issue has severity BROKEN und there is no workaround for Windows systems to fix it on the user side, or is there?

Selecting a custom installation of cli with a valid path to ng doesn't change anything to the error. Preferences dialog keeps saying ".../ng.cmd is not a ng file" regardless of which path is selected. Project specific settings can not be activated as long as this error persists ("The currently displayed page contains invalid values").

I am using the latest release from the marketplace, 1.3.0, CLI version is 6.0.8. Lower CLI versions force the same error.

trhsrw avatar Jun 14 '18 09:06 trhsrw

Could you try to use "install cli"? Maybe this could work. The problem is, that we have to parse the output of the command, to know the version of Angular CLI and this output might change in new versions.

probert94 avatar Jun 14 '18 09:06 probert94

@Springrbua I've tried that several times with different versions of CLI. Didn't work. It creates a project with just the node_modules folder in it. No src and e2e folders, no angular.json, package.json, tsconfig.json...

My point is not to blame you for your limited time. I think, many people could safe a lot of nerves and time if it was taken down from the marketplace as long as this is neither fixed nor a reasonable workaround is provided.

trhsrw avatar Jun 14 '18 09:06 trhsrw

Dear @angelozerr, shouldn't you take the plugin from the Eclipse Marketplace as long as this issue is not fixed?

is it working with snapshot update site? If yes, I think we should to create a new release.

angelozerr avatar Jun 14 '18 09:06 angelozerr

What is the snapshot update site and where can I find it?

My Eclipse is currently broken by this error, because I can't close the Angular CLI preferences page anymore ("The currently displayed page contains invalid values").

trhsrw avatar Jun 14 '18 09:06 trhsrw

What is the snapshot update site and where can I find it?

https://github.com/angelozerr/angular-eclipse/wiki/Installation-Update-Site

angelozerr avatar Jun 14 '18 09:06 angelozerr

Thanks a lot. I had tried .../1.4.0/ and .../1.4.0-SNAPSHOT/

I will give feedback here.

trhsrw avatar Jun 14 '18 10:06 trhsrw

The problem persists. I have checked the output of ng --version. That's kind of strange with ASCII art. I don't know, whether there is a variant of the --version option without ascii art. You won't be able to fix this as long as they keep playing around with crap like that in their version output.

You might want to consider a boolean option (checkbox) in the preferences / the new project dialog to skip CLI validation. Or something like: "use ng.cmd anyway, I know, what I'm doing." This might help most people with a standard installation of angular cli.

trhsrw avatar Jun 14 '18 11:06 trhsrw

Thanks for your feedback @trhsrw . I agree with you, this version search must perhaps be less restrictive. I must find time to study this problem and do something.

angelozerr avatar Jun 14 '18 11:06 angelozerr

I found a solution to "The 'ng' is not a ng file." problem. You have to have ng set in your $PATH before starting Eclipse IDE. After that you should be able to create new Angular projects with angelo's plugin, since the plugin should find ng from $PATH (global _preferences). For example: on your ~/.profile (or where ever your $PATH is set) file PATH="$PATH:/usr/lib/node_modules/@angular/cli/bin" Change Angular path to match your installation.

So this 'bug' seems to be more related to configuration.. Maybe this 'Global preference' should be editable so plugin would use users configuration instead of $PATH (if it is not found from $PATH) On Windows $PATH would mean your Environment variables...

I hope this helps.. it solved my case of "The 'ng' is not a ng file."

I'm using: Linux, Eclipse Oxygen 4.7.3a, Node.js 8.11.3, Angular CLI 6.0.8

JJN2 avatar Jun 19 '18 05:06 JJN2

PATH="$PATH:/usr/lib/node_modules//bin" --> PATH="$PATH:/usr/lib/node_modules/@angular/cli/bin" Sorry for that typo in example PATH setting

JJN2 avatar Jun 19 '18 05:06 JJN2

ah.. special character which is parsed away from text.. well anyways.. set Angular path in there.

JJN2 avatar Jun 19 '18 05:06 JJN2

@JJN2 If you select global cli, you should have angular-cli installed globally, by using npm install @angular/cli -g. This should install it in the global node_modules, which should be part of the path by default.
Basically, the plugin just executes ng --version, to check if a valid angular-cli version is available. If the ng-command is not part of the path, then it won't be able to execute it.
Usually, it is a good idea to install angukar-cli globally, if you are developing applications with it, because otherwise you won't be able to execute all the ng-commands easily.

probert94 avatar Jun 19 '18 06:06 probert94

Angular was installed globally with -g flag (as instructed in Angular web pages). It was globally usable since ng commands could be run from any folder location but $PATH settings were never modified by npm install -g ... Problem was that angular path was not defined in $PATH which is set by default in ~/.profile on Debian Jessie distro of Linux. Eclipse plugin for some reason needs Angular path defined in $PATH or it won't find ng at all when using Global preferences.

JJN2 avatar Jun 19 '18 06:06 JJN2

Problem is that the embedded nodejs is used inside the $PATH. You probably need to setup an external path for nodejs-first because the newest "@angular/cli" is not compatible with the embedded nodejs that gets used. The plugin uses embedded 6.9.4 by default wich won't work with the ng-command.

TheCrazyT avatar Oct 28 '18 09:10 TheCrazyT

I'm having the same problem 1 year later.

I've configured ng global Angular CLI: 8.3.6 is installed globally. Directory C:\Program Files\nodejs is in the path..

I've also configured to use "installed" node.js 10.16.3 in directory C:\Program Files\nodejs with same results.

Is there a fix/work around for windows 10?

garymazz avatar Sep 29 '19 02:09 garymazz

@garymazz: I ended up using the Eclipse WildWebDeveloper plugin (strongly recommended anyway) and the Angular CLI in Eclipse‘s terminal view. Works best for my purposes.

trhsrw avatar Sep 29 '19 08:09 trhsrw