Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng command not recognized in eclipse preference #107

Open
sayantansinha opened this issue Aug 12, 2017 · 43 comments
Open

ng command not recognized in eclipse preference #107

sayantansinha opened this issue Aug 12, 2017 · 43 comments

Comments

@sayantansinha
Copy link

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.

@angelozerr
Copy link
Owner

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?

@sayantansinha
Copy link
Author

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.

@probert94
Copy link
Contributor

probert94 commented Aug 12, 2017

@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.

@sayantansinha
Copy link
Author

@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
Copy link
Author

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.

@probert94
Copy link
Contributor

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 :)

@angelozerr
Copy link
Owner

@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!

@probert94
Copy link
Contributor

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

@angelozerr
Copy link
Owner

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!

@probert94
Copy link
Contributor

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?

@angelozerr
Copy link
Owner

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.

@probert94
Copy link
Contributor

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.

@angelozerr
Copy link
Owner

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!

@sayantansinha
Copy link
Author

sayantansinha commented Aug 14, 2017

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.

@probert94
Copy link
Contributor

@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
Copy link
Contributor

@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?

@angelozerr
Copy link
Owner

Yes it's a good idea.

@nitinkaveriappa
Copy link

nitinkaveriappa commented Feb 21, 2018

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

@sayantansinha
Copy link
Author

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

@angelozerr
Copy link
Owner

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

@nitinkaveriappa
Copy link

nitinkaveriappa commented Feb 22, 2018

@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

@angelozerr
Copy link
Owner

@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.

@nitinkaveriappa
Copy link

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

@angelozerr
Copy link
Owner

@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.

@manhbui21
Copy link

manhbui21 commented May 5, 2018

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

@angelozerr
Copy link
Owner

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

@trhsrw
Copy link

trhsrw commented Jun 14, 2018

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.

@probert94
Copy link
Contributor

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.

@trhsrw
Copy link

trhsrw commented Jun 14, 2018

@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.

@angelozerr
Copy link
Owner

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.

@trhsrw
Copy link

trhsrw commented Jun 14, 2018

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").

@angelozerr
Copy link
Owner

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

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

@trhsrw
Copy link

trhsrw commented Jun 14, 2018

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

I will give feedback here.

@trhsrw
Copy link

trhsrw commented Jun 14, 2018

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.

@angelozerr
Copy link
Owner

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.

@JJN2
Copy link

JJN2 commented Jun 19, 2018

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
Copy link

JJN2 commented Jun 19, 2018

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
Copy link

JJN2 commented Jun 19, 2018

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

@probert94
Copy link
Contributor

@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.

@JJN2
Copy link

JJN2 commented Jun 19, 2018

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.

@TheCrazyT
Copy link

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.

@garymazz
Copy link

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?

@trhsrw
Copy link

trhsrw commented Sep 29, 2019

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants