如何将NodeJS和node_modules添加到Mac App [英] How to add NodeJS and node_modules to a Mac App

查看:300
本文介绍了如何将NodeJS和node_modules添加到Mac App的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Mac App,该Mac App当前依赖于节点二进制文件的存在.这种方法的主要不便之处在于,由于App Store的限制,用户需要授予对节点二进制文件以及全局node_modules文件夹的访问权限.

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.

所以我的想法是将节点二进制文件以及所有需要的节点模块都添加到Mac App中,但是我不确定如何执行此操作.我知道您可以添加二进制文件,然后像这样使用它:

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:@""]];

我现在的问题是,如何告诉节点自定义node_modules的位置?

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

推荐答案

我在OS X App Store上发布了一个依赖于节点的应用程序.我最终要做的是将节点直接包含在我的应用程序目录中.节点将对文件系统进行爬网并使用它可以找到的第一个node_modules,因此您无需进行任何配置.

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:

这篇关于如何将NodeJS和node_modules添加到Mac App的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆