GerritErpenstein / ionic2-custom-icons

A npm-script for creating custom icon fonts and Angular 4 directives to render the icons in your Ionic 3 app.
MIT License
62 stars 15 forks source link

'ionic2-custom-icons' is not recognized as an internal or external command (Windows only) #31

Open ThorvaldAagaard opened 6 years ago

ThorvaldAagaard commented 6 years ago

I have been using your plugin for quite a while, but have recently moved ny apps to a new pc, and during that updated a lot of stuff.

My problem is that in one of my apps the building including your script is working fine, but in the other application I get an error.

The error looks like this

> npm run ionic:watch:before

> geme.io@0.4.0 ionic:watch:before D:\Documents\github\geme.io
> ionic2-custom-icons

'ionic2-custom-icons' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! geme.io@0.4.0 ionic:watch:before: `ionic2-custom-icons`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the geme.io@0.4.0 ionic:watch:before script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\thorvald.AALBORGDATA\AppData\Roaming\npm-cache\_logs\2017-12-26T01_00_55_452Z-debug.log
[ERROR] An error occurred while running npm run ionic:watch:before (exit code 1).

and the log file contains

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'ionic:watch:before' ]
2 info using npm@5.5.1
3 info using node@v8.9.3
4 verbose run-script [ 'preionic:watch:before',
4 verbose run-script   'ionic:watch:before',
4 verbose run-script   'postionic:watch:before' ]
5 info lifecycle geme.io@0.4.0~preionic:watch:before: geme.io@0.4.0
6 info lifecycle geme.io@0.4.0~ionic:watch:before: geme.io@0.4.0
7 verbose lifecycle geme.io@0.4.0~ionic:watch:before: unsafe-perm in lifecycle true
8 verbose lifecycle geme.io@0.4.0~ionic:watch:before: PATH: C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin;D:\Documents\github\geme.io\node_modules\.bin;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\Program Files\dotnet\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\SourceGear\Common\DiffMerge\;C:\Program Files (x86)\Windows Live\Shared;D:\Documents\Android\Sdk\tools;D:\Documents\Android\Sdk\platform-tools;C:\Program Files\Git\usr\bin;C:\Program Files\Java\jdk1.8.0_152\bin;C:\Users\thorvald.AALBORGDATA\AppData\Local\Microsoft\WindowsApps;C:\Users\thorvald.AALBORGDATA\AppData\Local\Programs\Fiddler;C:\Users\thorvald.AALBORGDATA\AppData\Roaming\npm
9 verbose lifecycle geme.io@0.4.0~ionic:watch:before: CWD: D:\Documents\github\geme.io
10 silly lifecycle geme.io@0.4.0~ionic:watch:before: Args: [ '/d /s /c', 'ionic2-custom-icons' ]
11 silly lifecycle geme.io@0.4.0~ionic:watch:before: Returned: code: 1  signal: null
12 info lifecycle geme.io@0.4.0~ionic:watch:before: Failed to exec ionic:watch:before script
13 verbose stack Error: geme.io@0.4.0 ionic:watch:before: `ionic2-custom-icons`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid geme.io@0.4.0
15 verbose cwd D:\Documents\github\geme.io
16 verbose Windows_NT 10.0.16299
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:watch:before"
18 verbose node v8.9.3
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 1
22 error geme.io@0.4.0 ionic:watch:before: `ionic2-custom-icons`
22 error Exit status 1
23 error Failed at the geme.io@0.4.0 ionic:watch:before script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

And in the other project the output looks like this

> npm run ionic:watch:before

> Geme@ ionic:watch:before D:\Documents\github\Geme
> ionic2-custom-icons

[02:07:54]
ionic2-custom-icons: Creating custom icon set 'geme'
[02:07:54]
ionic2-custom-icons: Creating custom icon set 'gemeTab'
[02:07:54]
gulp-svgicons2svgfont: Font created
[02:07:55] gulp-svgicons2svgfont: Font created
ionic2-custom-icons: Successfully created icons

I have tried remove and reinstall the plugin, the platform etc but nothing seems to help.

Unfortunately I don't have access to my old machine to verify it still works there

The really strange thing is that if I execute the command from the log-file:

D:\Documents\github\geme.io>"C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:build:before"

> geme.io@0.4.0 ionic:build:before D:\Documents\github\geme.io
> ionic2-custom-icons

[02:18:38] ionic2-custom-icons: Creating custom icon set 'geme'
[02:18:38] ionic2-custom-icons: Creating custom icon set 'gemeTab'
[02:18:38] gulp-svgicons2svgfont: Font created
[02:18:38] gulp-svgicons2svgfont: Font created
ionic2-custom-icons: Successfully created icons

The result looks ok ?

Any idea about what I can be missing?


It seems it is only inside Visual Studio I have this problem


GerritErpenstein commented 6 years ago

Hi @ThorvaldAagaard! Can you please check if the file/link exists in your project: node-modules/.bin/ionic2-custom-icons? According to your logs the full path should be D:\Documents\github\geme.io\node_modules\.bin\ionic2-custom-icons. This is the file that gets called by the trigger ionic:watch:before respectively ionic:build:before.

ThorvaldAagaard commented 6 years ago

The file is there. As I am running windows I expect the

D:\Documents\github\geme.io\node_modules\.bin\ionic2-custom-icons.cmd

to be executed.

So I added a single output line in it, and I can see it is executed, when run Ionic Serve outside VS Code, but not inside.

So how does ionic serve know where to look for the file?

GerritErpenstein commented 6 years ago

I have absolutely no clue why the code runs fine outside Visual Studio Code and fails inside. I'm afraid I can't give you any support on that problem as I'm not using VS Code. But I don't think it is directly related to this library. Please let me if you find a solution.

ThorvaldAagaard commented 6 years ago

Indeed a very strange problem.

I copied the folder: Same issue Cleared NPM-cached and reinstalled all plugins: Same issue Created a new project and copied Source, config, icons and project files: Same issue

Working my way thru I created a starter project at copied all source-files after adding ionic2-custom-icons first, and it still worked. Copied the rest of the files and now it failed, and it seemed like it was package.json that was the problem. Then I moved the config section for ionic2-custom-icons up before the script section, and voila, now it works.

I tried just to move the config in the old project, but that did not help.

But I think I have wasted enough time on that now, as I now again have a working project inside VS Code.

Thx for taking the time to respond, sometimes it is good just to describe the problem :-) I will close this now

ThorvaldAagaard commented 6 years ago

A have learned a little more as it seems that as soon as I add another element in config I get the error

This works

  "config": {
    "ionic_copy": "./config/copy.config.js",   
    "ionic_sass": "./config/sass.config.js",
    "custom_icons": "./config/custom-icons.config.js"
  },

This doesnt work

  "config": {
    "ionic_generate_source_map": "true",
    "ionic_copy": "./config/copy.config.js",   
    "ionic_sass": "./config/sass.config.js",
    "custom_icons": "./config/custom-icons.config.js"
  },

But this work

  "config": {
    "ionic_generate_source_map": "true",
    "ionic_copy": "./config/copy.config.js",   
    "custom_icons": "./config/custom-icons.config.js"
  },
niklasdoerflerkrone commented 6 years ago

Did you found out, what caused the problem, @ThorvaldAagaard ? I have exactly the same behaviour. If I run the command in a terminal or powershell on Windows 10, it works and the ionic2-custom-icons script is executed correctly. But if I try to run it in the integrated terminal of Visual Studio Code, I get the same error you described above. Your suggestions modifying the package.json didn't do the trick for me. Thanks in advance!

GerritErpenstein commented 6 years ago

I was finally able to reproduce this problem on a Windows machine. For some reason when ionic-cli calls the npm scripts (from package.json) the executables in node_modules/.bin aren't available. Strangely enough this works if I call the npm scripts from the command line outside the Ionic lifecycle. Currently I have no idea what causes this problem. Maybe the way ionic-cli calls npm!?

A workaround is to provide a path to the target script of the library. Edit the scripts ionic:watch:before and ionic:build:before in your package.json like this:

...

"ionic:watch:before": "node ./node_modules/ionic2-custom-icons/npm-script/bin/ionic2-custom-icons.js",
"ionic:build:before": "node ./node_modules/ionic2-custom-icons/npm-script/bin/ionic2-custom-icons.js",
...

Note: As far as I know this problem only occurs on Windows and not for all users.

ThorvaldAagaard commented 6 years ago

Great. Lately this happens to me a lot of time using visual code.

Even in a cmd prompt I have seen it. My work around is now. Execute script. If it fails execute again. After 3 failing attempts, go get some coffee. When returning it normally works 😁.

I will try your suggestion and return with status

ritsuFR commented 6 years ago

I have the same problem on Windows 10. I find another workaround by installing the plugin globally with :

npm install -g ionic2-custom-icons --save

ThorvaldAagaard commented 6 years ago

I can try that, but after applying the change suggested by Gerrit, it has been working fine