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

Eclipse preferences: The '/usr/local/lib/node_modules/@angular/cli/bin/ng' is not a ng file. #64

Open
javaspeak opened this issue Mar 19, 2017 · 40 comments

Comments

@javaspeak
Copy link

Hi Angelo and other Devs,

I am using a Mac and have installed "http://oss.opensagres.fr/angular2-eclipse/1.2.0-SNAPSHOT/" into NEON.

When I go to:

 Eclipse ==> Preferences ==> JavaScript ==> Typescript ==> Angualr2 ==> CLI 

it says at the top of the window:

The '/usr/local/lib/node_modules/@angular/cli/bin/ng' is not a ng file.

However there is a shell script ng file in the location:

  $ ls -ltr /usr/local/lib/node_modules/@angular/cli/bin/
 total 16
 -rwxr-xr-x  1 nobody  staff  5982 Mar 14 02:35 ng

I am not sure if this a permission problem or that the eclipse plugin is expecting a different format ng file. Like I said this ng file in the above location is a shell script. The eclipse plugin found the location by itself - I did not choose it.

I did previously run this command before installing the angular2-eclipse plugin:

 sudo npm install -g @angular/cli

Because of this configuration problem if I do:

  File ==> New Angular 2 Project

and try to create a new project it shows in the Terminal window:

~/Documents/workspace$ ng new bling
bash: ng: command not found

Incidentally because of this failure, no project is created at all on the file system when trying to create a Angular 2 project.

Finally if I type on the command line :

which ng

I get:

 $ which ng
/usr/local/bin/ng

Maybe the eclipse plugin could try that location instead. For some reason If in the above preference section of eclipse and I select the radio button "Use ng custom file" and try and navigate to "/usr/local/bin/ng" I cannot access the path. Maybe this a Mac feature of eclipse.

Not sure if I have given enough information for you to know what the problem is.

Thank you for your time and your contribution to this plugin

@angelozerr
Copy link
Owner

The '/usr/local/lib/node_modules/@angular/cli/bin/ng' is a JavaScript file which must be executed with node When you install @angular/cli globally, it install the /usr/local/bin/ng which basicly does 'node /usr/local/lib/node_modules/@angular/cli/bin/ng'.

So the well file is "/usr/local/bin/ng" as you have said ($ which ng).

For some reason If in the above preference section of eclipse and I select the radio button "Use ng custom file" and try and navigate to "/usr/local/bin/ng" I cannot access the path. Maybe this a Mac feature of eclipse.

The "Use ng custom file" waits for a directory (and not the file) which contains the ng/ng.cmd file. So you should select "/usr/local/bin/" and not "/usr/local/bin/ng".

When Terminal is opened, it adds in the env path this directory before opening the terminal. If you have not admin privilege, you can use directly the ng file. See #56 (comment)

@tiramon
Copy link

tiramon commented Mar 30, 2017

i just tried to set this up on a mac too

i tried "/usr/local/bin/" as you said, i also tried to install cli local in my workspace and i always get the same error.

I guess it's the @ in the path, because "/usr/local/bin/ng" is only a symbolic link to '/usr/local/lib/node_modules/@angular/cli/bin/ng'
and if i want to cd to the cli bin folder i have to escape the @ like this

cd /usr/local/lib/node_modules/\@angular/cli/bin/

i guess you also have to escape the @ in your call, if this does not fix it i'm out of ideas how to get it working

if i execute a
export PATH=$PATH:/usr/local/lib/node_modules/\@angular/cli/bin
in the terminal it works for me

@tiramon
Copy link

tiramon commented Mar 30, 2017

but i still get problems when i try to run ng serve etc, even when i do a export in that terminal window

it tells me
node_modules appears empty, you may need to run npm install

@angelozerr
Copy link
Owner

export PATH=$PATH:/usr/local/lib/node_modules/@angular/cli/bin

Thanks for this information.

but i still get problems when i try to run ng serve etc, even when i do a export in that terminal window

Once your ng project is created, you should have a .bin folder inside your project which contains the ng. Try to modify this properties with ng custom file.

@angelozerr
Copy link
Owner

@tiramon please reinstall 1.2.0 and tell me if your problem dispapear, thanks

@angelozerr
Copy link
Owner

@tiramon could you tell me if it works now please?

@angelozerr
Copy link
Owner

None answer, I close this issue. @tiramon please install 1.2.0 release, if you have problem again, please reopen it.

@tokiaquino
Copy link

tokiaquino commented Nov 3, 2017

@angelozerr
I have the same problems when configure Eclipse global preferences

imagen

@tokiaquino
Copy link

And when create an Agular Project, stay " Searching for global Angular CLI..."
imagen

@tokiaquino
Copy link

And when create an Agular Project, stay " Searching for global Angular CLI..."

imagen

@angelozerr
Copy link
Owner

@Springrbua could you help us with this issue please?

@probert94
Copy link
Contributor

@tokiaquino are you using latest (1.4 Snapshot) version?
I just had a look at my installation and there it says "use global preferences" instead of "use global" as in your case.
In the latest version it is possible, to use the CLI-Installation you configure in the global preferences, instead of just the global CLI-Installation.

@tokiaquino
Copy link

@Springrbua i confirm on monday because is in my work computer, but i have the same problem when configure global preference like i mention on previous comment

@probert94
Copy link
Contributor

@tokiaquino yea there were a few issues with the cli-settings in the 1.3 version. The ones I know about should be fixed with latest snapshot.
You might need to change the update side to get the update to the latest version.

@tokiaquino
Copy link

Thanks @Springrbua, like you said, i have 1.3 version, now i update to 1.4.
Beside on that, i had installed globally @ angular/[email protected], and stil have the message "It's not ng file" when want to configure global preference.
But if i downgrade to @ angular/[email protected] it's recognize without problem.

imagen

@angelozerr
Copy link
Owner

@tokiaquino I see the problem now. I will try to fix this night.

angelozerr added a commit that referenced this issue Nov 6, 2017
@angelozerr
Copy link
Owner

@tokiaquino please reinstall snpashot and tell me if it works for you.

@tokiaquino
Copy link

I don't have the message "It's not ng file" in the global preferences any more, but seems it's not checking the ng, neither Use ng global configuration or Use ng custom installation

imagen

When I want create a "Angular Project"
If check the "Use global preferences" have an "No Angular CLI installation found in global preferences." message
imagen

But, if you check "Install", when you click "Finish", install all the node modules with the npm install command
imagen

These are my installation details, if needed to help
imagen

@angelozerr angelozerr reopened this Nov 7, 2017
@angelozerr
Copy link
Owner

angelozerr commented Nov 7, 2017

@tokiaquino my fix was to support Angular CLI 1.5

I don't have the message "It's not ng file" in the global preferences any more, but seems it's not checking the ng, neither Use ng global configuration or Use ng custom installation

Right it's since #110

@Springrbua I think we should rethink the logic of validation in global preferences. IMHI I think we should validate:

  • Use ng global configuration every time
  • Use ng custom location only when we have never $project_loc.

What do you think guys about that?

@probert94
Copy link
Contributor

@angelozerr the global oreferences should always validate the global cli. The custom cli is never validated, as it might be project dependent.
When I tested it last time, it worked as expected, but I'll check it again asap. Maybe I missed some cases, which cause the bug.

@angelozerr
Copy link
Owner

@Springrbua validation is never done in global preferences because of https://github.com/angelozerr/angular-eclipse/blob/master/ts.eclipse.ide.angular.cli/src/ts/eclipse/ide/angular/internal/cli/preferences/AngularCLIConfigurationBlock.java#L313

I think we should validate:

  • Use ng global installation like in the project preferences. It uses the ng installaed with npm install -g @angular/cli
  • Use ng custom location only when $project_loc is not used. This use case is the case of @tokiaquino which have filled with /usr/local/bin but IMHO I think Use ng global installation should be better to use.

I think too, we should add a button Open in the Angular Project wizard on the right of Use ng global installation which opens the Global Preferences. @dSpringrbua you have a sample of code to open preferences at https://github.com/angelozerr/typescript.java/blob/master/eclipse/ts.eclipse.ide.ui/src/ts/eclipse/ide/ui/preferences/PropertyAndPreferencePage.java#L217 and use the page id https://github.com/angelozerr/angular-eclipse/blob/master/ts.eclipse.ide.angular.cli/src/ts/eclipse/ide/angular/internal/cli/preferences/AngularCLIPreferencePage.java#L26

Once the preferences is changed, validation should be doen again. @Springrbua is there any chance that you implement that? Thanks for your help.

@tokiaquino
Copy link

Use ng global configuration every time
Use ng custom location only when we have never $project_loc.

In global preference
Whats is the need of configure ng custom location?
Is not enough to indicate if or if not I had CLI installed globally?

@probert94
Copy link
Contributor

@angelozerr The use global is already validated, also in global prefs (see a few lines before the position you linked). But we should also validate custom location as you said.
@tokiaquino the custom installation is only, if you don't have cli installed globally (npm install -g) but in a custom directory somewhere on your drive

@divStar
Copy link

divStar commented Nov 25, 2017

I just wanted to throw in, that in 1.3.0 of this plugin the "Use ng global" radio button did not work and neither did setting the folder manually (it said that the folder given is not an ng file).

With 1.4.0 (SNAPSHOT), nodejs 8.9.1 and angular 1.5.4 (installed globally) it worked - though it keeps offering me nodejs 6.x-something (embedded) by default - which is a bit annoying as I am not intending to use that.

Basically: it seems to work with 1.4.0. Thanks :).

@josersleal
Copy link

Sorry not working for me...

I am able to create one project but that is it... next project on the same workspace fails with No Angular CLI installation found in global preferences.'

This is a major CF...

You guys need to create and run tests..

@angelozerr
Copy link
Owner

You guys need to create and run tests..

@josersleal please note that we develop this plugin in our free time. More we have Windows OS, it's difficult for me and @Springrbua to test with another OS. So if you have problem, please help us, thanks.

For run tests, please give us suggestion, I don't know how to write tests for this issue, please help us.

@probert94
Copy link
Contributor

@josersleal @angelozerr I am waiting for my new notebook, which I should get the next weak.
I'll then take a look at it, I know, the CLI-Settings is causing some trouble...
@josersleal as @angelozerr said, we are working on this in our free time. Also it is an open source project, so you are free to contribute to it.
Any help is very welcome :)

@jfrantzius
Copy link

With 1.3.x on Mac I also saw the original error reported in this issue (though with a different install location of ng, but I guess that doesn't matter). After upgrading to current 1.4.x, the error went away.

However, I had to manually de-install the 1.3.x feature, because the feature name seems to have changed between versions. Before de-installing the old feature, I was seeing two "Angular" preference sections, out of which one was still showing the reported error.

So as I'd see it, the original error is fixed in 1.4.x on Mac ...

@angelozerr
Copy link
Owner

angelozerr commented Dec 1, 2017

So as I'd see it, the original error is fixed in 1.4.x on Mac ...

@jfrantzius thanks for your feedback!

With 1.4.0 (SNAPSHOT), nodejs 8.9.1 and angular 1.5.4 (installed globally) it worked - though it keeps offering me nodejs 6.x-something (embedded) by default - which is a bit annoying as I am not intending to use that.

@divStar Please reinstall 1.4.0 (SNAPSHOT), nodejs 8.9.1 should be available as embed nodejs (see angelozerr/typescript.java#222), hope it will work for you.

@stephaneeybert
Copy link

stephaneeybert commented Mar 15, 2018

On Eclipse Neon 3 (4.6.3) and Angular Eclipse 1.3.0 I also get the same message:

The '/home/stephane/.nvm/versions/node/v9.7.1/lib/node_modules/@angular/cli/bin/ng' is not a ng file.

$ which ng
/home/stephane/.nvm/versions/node/v9.7.1/bin/ng
[stephane@stephane-ThinkPad-X201 ~]
$ file /home/stephane/.nvm/versions/node/v9.7.1/bin/ng
/home/stephane/.nvm/versions/node/v9.7.1/bin/ng: symbolic link to ../lib/node_modules/@angular/cli/bin/ng
[stephane@stephane-ThinkPad-X201 ~]
$ file /home/stephane/.nvm/versions/node/v9.7.1/lib/node_modules/@angular/cli/bin/ng
/home/stephane/.nvm/versions/node/v9.7.1/lib/node_modules/@angular/cli/bin/ng: a /usr/bin/env node script, ASCII text executable
[stephane@stephane-ThinkPad-X201 ~]
$ ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.7.2
Node: 9.7.1
OS: linux x64
Angular: 
...
$ /home/stephane/.nvm/versions/node/v9.7.1/bin/ng -v

    _                      _                 ____ _     ___
   / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
  / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
 / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
/_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
               |___/
    
Angular CLI: 1.7.2
Node: 9.7.1
OS: linux x64
Angular: 
...

On Lubuntu 16.04

@angelozerr
Copy link
Owner

@stephaneeybert
Copy link

@angelozerr Thanks for the suggestion. I see a number of files in that directory. I don't know what to do with these files. You have a few guiding instructions ? Cheers.

@probert94
Copy link
Contributor

@stephaneeybert you only need to use http://oss.opensagres.fr/angular-eclipse/snapshot/ as update site for the plugin.
I would uninstall the older version (1.3.0) first and then use this URL to install the plugin.

@stephaneeybert
Copy link

@angelozerr After removing the plugin, I tried to add software from the given url but my Eclipse could not perform the operation and hanged trying to find alternate solutions.

@sayantansinha
Copy link

@angelozerr @Springrbua have you guys added support for Angular-CLI 6?

@armita-burjwal
Copy link

Any update on this??

@armita-burjwal
Copy link

After adding 1.4.0 when i create a new project it is showing " No Angular CLI installation found in global preferences."

@Tony-Esales
Copy link

I'm getting the same error pointed by @javaspeak. The ng file exists and it's working fine, but some validation is telling the file is not a ng file (that is not true). I have installed globally Angular CLI version 8.0.4.
Eclipse version: 2019-06
Plugin version: latest (just installed it by Eclipse Marketplace

@angelozerr Can you help me?

@probert94
Copy link
Contributor

@Tony-Esales the Plugin hasn't been updated since a while and the Angular CLI changed quite a bit in that time. My guess is, that the command used to check the validity of the ng-file has been changed or even removed.

@angelozerr
Copy link
Owner

@angelozerr Can you help me?

I'm sorry guys but I have no time to continue this project. The new Angular support inside Eclipse is inside the new project https://github.com/eclipse/wildwebdeveloper but ng is not included for the moment eclipse-wildwebdeveloper/wildwebdeveloper#147

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