Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add NodeJS and node_modules to a Mac App

I am writing a Mac App that currently relies on the presence of a node binary. The main inconvenience with this approach is, that the user needs to grant access to the node binary as well as the global node_modules folder due to App Store restrictions.

So my idea is to add both the node binary as well as all needed node modules to the Mac App, but I'm not sure how to do this. I know you can add the binary and then use it like this:

[task setLaunchPath:[[NSBundle mainBundle] pathForResource:@"node" ofType:@""]];

My question now is, how do I tell node about the custom node_modules location?

like image 221
Kevin Smith Avatar asked May 01 '14 07:05

Kevin Smith


1 Answers

I shipped an app on the OS X App Store that relies on node. What I ended up doing was include node directly in my app directory. node will crawl the filesystem and use the first node_modules it can find, so you don't have to configure anything.

Here's the structure I eventually used:

enter image description here

like image 177
Laurent Perrin Avatar answered Sep 28 '22 18:09

Laurent Perrin