Error : Hook failed with error code 1 - Linting and Uglifying issue


#1

I have a : Hook failed with error code 1. And then no errors on scanned files before… Can anyone have any idea…?

Error: Hook failed with error code 1: C:\Users\Usr\Dev\WAIJ\hooks\before_prepare\02_jshint.js
    at C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\cordova-lib\src\hooks\HooksRunner.js:194:23
    at _rejected (C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:808:24)
    at C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:834:30
    at Promise.when (C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:1079:31)
    at Promise.promise.promiseDispatch (C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:752:41)
    at C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:574:44
    at flush (C:\Users\Usr\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
    at process._tickCallback (node.js:419:13)

#2

Sorry @nicraboy to bother you…
I had to disable the linting because of this error.
Do you have any recommendation in order to be able to understand this error ?
Thank you.


#3

Does this version work any better for you?:

I’ve heard a lot of reports that Windows is having trouble with jshint. On my Mac, and other peoples Macs, I’ve seen no issues.

Let me know if you’re using the asynchronous or synchronous version of my code. I have two floating around.

Regards,


#4

Hi,
I think I’m using the Async version like you explained it in the ionic blog.

The issue is not showing when the
var foldersToProcess is an empty array.
I’m having something like 15 folders with separated js files to scan…

I tried your new version with my “foldersToProcess” array and all of my files and the issue is showing as well…
I don’t know how to detect which file is in error.


#5

Hi @nicraboy
I found the origin of the error :

I did add a ; to a function.

function getRandomInt(min, max) {
    return Math.floor(Math.random() * (max - min + 1)) + min;
}**[here ;]**

I don’t understand why the linter crashing with that.


#6

Hi Guys, for the first time I’m going for a “production-phase” following this tutorial…https://www.airpair.com/ionic-framework/posts/production-ready-apps-with-ionic-framework
but for the lint phase I have the same issue @ronycohen …can u help me with or share your solution?

Actually, if I skip the lint phase I’m able to enable ng-strict-di and making the concatenation…but for Uglify, minify and obfuscate phase I have the same issue!

Thanks in advance


#7

Hey @fase,

Update your stuffs with "NPM update jshint"
You need the last version.

Also you can do a “ionic state reset” to make sure everything is fine.


#8

@ronycohen thanks for fast reply!

Well, I’m actually able to make the build (and produce the android-debug.apk)…now the issues are 2:

  1. ionic state reset --> state is not a valid task

  2. during the build (that ends correctly but produce this error…):
    processFiles err: Error: ENOENT, scandir '/Users/Vitali/Desktop/cartella senza titolo 3/frontend-adolescenti/platforms/android/assets/www/dist_js’
    processFiles err: Error: ENOENT, scandir '/Users/Vitali/Desktop/cartella senza titolo 3/frontend-adolescenti/platforms/android/assets/www/dist_css’
    Running command: “/Users/Vitali/Desktop/cartella senza titolo 3/frontend-adolescenti/platforms/android/cordova/run”

  3. I can’t run now the apk

…/platforms/android/cordova/node_modules/q/q.js:126
throw e;
^
ERROR: Failed to launch application on device: ERROR: Failed to install apk to device: pkg: /data/local/tmp/android-debug.apk

Do u know something about this?
I have a little bit confusion about the debug apk and the release apk
(if can help i run the buid and run with both Ionic and Cordova with the same results!)


#9

Hi,

You should update everything
Cordova, Ionic CLI, Ionic Lib.