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

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

Open javaspeak opened this issue 7 years ago • 40 comments

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

javaspeak avatar Mar 19 '17 11:03 javaspeak

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 https://github.com/angelozerr/angular2-eclipse/issues/56#issuecomment-285664486

angelozerr avatar Mar 24 '17 08:03 angelozerr

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 avatar Mar 30 '17 17:03 tiramon

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

tiramon avatar Mar 30 '17 18:03 tiramon

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 avatar Mar 30 '17 20:03 angelozerr

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

angelozerr avatar Apr 09 '17 19:04 angelozerr

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

angelozerr avatar Apr 12 '17 16:04 angelozerr

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

angelozerr avatar Apr 17 '17 23:04 angelozerr

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

imagen

tokiaquino avatar Nov 03 '17 11:11 tokiaquino

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

tokiaquino avatar Nov 03 '17 14:11 tokiaquino

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

imagen

tokiaquino avatar Nov 03 '17 17:11 tokiaquino

@Springrbua could you help us with this issue please?

angelozerr avatar Nov 03 '17 19:11 angelozerr

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

probert94 avatar Nov 04 '17 12:11 probert94

@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

tokiaquino avatar Nov 04 '17 14:11 tokiaquino

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

probert94 avatar Nov 04 '17 17:11 probert94

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

tokiaquino avatar Nov 06 '17 13:11 tokiaquino

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

angelozerr avatar Nov 06 '17 13:11 angelozerr

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

angelozerr avatar Nov 06 '17 19:11 angelozerr

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

tokiaquino avatar Nov 06 '17 21:11 tokiaquino

@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 https://github.com/angelozerr/angular-eclipse/pull/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?

angelozerr avatar Nov 07 '17 04:11 angelozerr

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

probert94 avatar Nov 07 '17 11:11 probert94

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

angelozerr avatar Nov 07 '17 11:11 angelozerr

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?

tokiaquino avatar Nov 07 '17 13:11 tokiaquino

@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

probert94 avatar Nov 07 '17 14:11 probert94

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

divStar avatar Nov 25 '17 05:11 divStar

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

josersleal avatar Nov 30 '17 11:11 josersleal

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.

angelozerr avatar Nov 30 '17 11:11 angelozerr

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

probert94 avatar Nov 30 '17 13:11 probert94

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

jfrantzius avatar Dec 01 '17 16:12 jfrantzius

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 https://github.com/angelozerr/typescript.java/issues/222), hope it will work for you.

angelozerr avatar Dec 01 '17 16:12 angelozerr

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

stephaneeybert avatar Mar 15 '18 17:03 stephaneeybert

@stephaneeybert please try 1.4.0 which is not released https://github.com/angelozerr/angular-eclipse/wiki/Installation-Update-Site#140-snapshot-snapshot

angelozerr avatar Mar 15 '18 19:03 angelozerr

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

stephaneeybert avatar Mar 16 '18 10:03 stephaneeybert

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

probert94 avatar Mar 16 '18 13:03 probert94

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

stephaneeybert avatar Mar 16 '18 14:03 stephaneeybert

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

sayantansinha avatar Aug 17 '18 19:08 sayantansinha

Any update on this??

armita-burjwal avatar Sep 25 '18 16:09 armita-burjwal

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

armita-burjwal avatar Sep 26 '18 07:09 armita-burjwal

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?

Tony-Esales avatar Jun 26 '19 12:06 Tony-Esales

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

probert94 avatar Jun 26 '19 12:06 probert94

@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 https://github.com/eclipse/wildwebdeveloper/issues/147

angelozerr avatar Jun 26 '19 13:06 angelozerr