Ionic browserify


#1

I’d like to use this npm module in my ionic app. Is there a way to use browserify with ionic?


#2

Since browserify is synchronously, yeah it should work.

Check out this presentation about using browserify with angular
http://benclinkinbeard.com/talks/2014/ng-conf/#/12

And this SO question


Using a NPM module in my ionic framework app
#3

I was also interested in using browserify along with ionic and I created an example project structure. This also uses gulp, sass, and napa for client dependency management. In case anyone finds it useful below is a link.


#4

cmackay, I don’t see your usage of browserify. How are you using it?


#5

The gulp file is using watchify which is part of browserify.


#6

I’m trying to use browserify to use this node-module for sending vehicle OBD commands and receiving responses back from a vehicle ECU.

I used npm install serial-obd to install the node-module in my ionic application.

I then cd node_modules/serial-obd/lib

and run browserify obd.js -o ../../../checkin/factories/obd.js from the command line

I add the <script src="checkin/factories/obd.js"></script> to my index.html

But when I build from the command line ionic run android I get the following error;

BUILD FAILED
/Users/Brad/Documents/dev_envs/android-sdk-macosx/tools/ant/build.xml:928: The following error occurred while executing this line:
/Users/Brad/Documents/dev_envs/android-sdk-macosx/tools/ant/build.xml:946:     java.lang.ArrayIndexOutOfBoundsException: 1
at com.android.ant.DependencyGraph.parseDependencyFile(DependencyGraph.java:180)
at com.android.ant.DependencyGraph.<init>(DependencyGraph.java:54)
at com.android.ant.SingleDependencyTask.initDependencies(SingleDependencyTask.java:87)
at com.android.ant.AaptExecTask.execute(AaptExecTask.java:509)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:124)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
at org.apache.tools.ant.Main.runBuild(Main.java:853)
at org.apache.tools.ant.Main.startAnt(Main.java:235)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)

Total time: 4 seconds

/Users/Brad/Documents/synchroClient/platforms/android/cordova/node_modules/q/q.js:126
                throw e;
                      ^
Error code 1 for command: ant with args: debug,-f,/Users/Brad/Documents/synchroClient/platforms/android/build.xml,-Dout.dir=ant-build,-Dgen.absolute.dir=ant-gen

#7

Here you can find some useful gulp tasks:

And one of those is about browserify: