Skip to content

ng command not recognized in eclipse preference #107

Open

Description

@sayantansinha

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.

Activity

  1. angelozerr commented on Aug 12, 2017

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

  2. sayantansinha commented on Aug 12, 2017

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

  3. probert94 commented on Aug 12, 2017

    @probert94
    Contributor

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

  4. sayantansinha commented on Aug 12, 2017

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

  5. sayantansinha commented on Aug 12, 2017

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

  6. probert94 commented on Aug 13, 2017

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

  7. angelozerr commented on Aug 13, 2017

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

  8. probert94 commented on Aug 14, 2017

    @probert94
    Contributor

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

  9. angelozerr commented on Aug 14, 2017

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

  10. probert94 commented on Aug 14, 2017

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

  11. angelozerr commented on Aug 14, 2017

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

  12. probert94 commented on Aug 14, 2017

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

  13. angelozerr commented on Aug 14, 2017

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

  14. sayantansinha commented on Aug 14, 2017

    @sayantansinha
    Author

    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.

  15. probert94 commented on Aug 15, 2017

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

  16. 13 remaining items

  17. trhsrw commented on Jun 14, 2018

    @trhsrw

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

  18. angelozerr commented on Jun 14, 2018

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

  19. trhsrw commented on Jun 14, 2018

    @trhsrw

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

  20. angelozerr commented on Jun 14, 2018

    @angelozerr
    Owner

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

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

  21. trhsrw commented on Jun 14, 2018

    @trhsrw

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

    I will give feedback here.

  22. trhsrw commented on Jun 14, 2018

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

  23. angelozerr commented on Jun 14, 2018

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

  24. JJN2 commented on Jun 19, 2018

    @JJN2

    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

  25. JJN2 commented on Jun 19, 2018

    @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

  26. JJN2 commented on Jun 19, 2018

    @JJN2

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

  27. probert94 commented on Jun 19, 2018

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

  28. JJN2 commented on Jun 19, 2018

    @JJN2

    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.

  29. TheCrazyT commented on Oct 28, 2018

    @TheCrazyT

    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.

  30. garymazz commented on Sep 29, 2019

    @garymazz

    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?

  31. trhsrw commented on Sep 29, 2019

    @trhsrw

    @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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions