my name my name -4 years ago 183
Android Question

Ionic - Error: Cannot find module 'jshint' while building a release.apk

I am new in this. I am developing an app in ionic framework. and now i want to create a build of release.apk. and i am referring following tutorial to build release.apk -

http://forum.ionicframework.com/t/ionic-toturial-for-building-a-release-apk/15758

but in this tutorial on #7 when i run

ionic build android --release
command then i am facing following error -

module.js:338
throw err;
^
Error: Cannot find module 'jshint'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/directory/appname/hooks/before_prepare/01_jshint.js:5:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
Error: Hook failed with error code 1: /directory/appname/hooks/before_prepare/01_jshint.js
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:194:23
at _rejected (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:797:24)
at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:823:30
at Promise.when (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:1035:31)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:741:41)
at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:557:44
at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
at process._tickCallback (node.js:355:11)


Question - How could i resolve this error? anyone please suggest me what's wrong with this?

Thanks in advance!

Answer Source

Well the installed hook located at PROJECT_ROOT/hooks/before_prepare/01_jshint.js requires the node module jshint. You can install it using NPM:

npm install jshint

You can also save this dependency to your package.json:

npm install jshint --save

If you set up the project on another computer or a different directory you could just type npm install to install all the project's dependencies.

If you run into more errors after this one, look at the error thrown and search for the text Cannot find module 'jshint'. Where the text jshint will be something different. Perhaps more NPM modules are missing. Install these on the same way you did for jshint.

Also note that JSHint will exit the build process once it finds any errors in your Javascript files. Scroll true all output to find the error reporting.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download