angelozerr / angular-eclipse

Angular Eclipse Plugin
https://angular.io/
Eclipse Public License 1.0
69 stars 12 forks source link

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

Open javaspeak opened 7 years ago

javaspeak commented 7 years ago

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 commented 7 years ago

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

tiramon commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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 commented 7 years ago

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

angelozerr commented 7 years ago

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

angelozerr commented 7 years ago

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

tokiaquino commented 7 years ago

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

imagen
tokiaquino commented 7 years ago

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

imagen
tokiaquino commented 7 years ago

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

imagen
angelozerr commented 7 years ago

@Springrbua could you help us with this issue please?

probert94 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

@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 commented 7 years ago

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

imagen
angelozerr commented 7 years ago

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

angelozerr commented 7 years ago

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

tokiaquino commented 7 years ago

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 commented 7 years ago

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

What do you think guys about that?

probert94 commented 7 years ago

@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 commented 7 years ago

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

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 commented 7 years ago

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 commented 7 years ago

@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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

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 commented 6 years ago

@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 commented 6 years ago

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 commented 6 years ago

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.

stephaneeybert commented 6 years ago

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 commented 6 years ago

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

stephaneeybert commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

@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 commented 6 years ago

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

armita-burjwal commented 6 years ago

Any update on this??

armita-burjwal commented 6 years ago

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

Tony-Esales commented 5 years ago

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 commented 5 years ago

@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 commented 5 years ago

@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