我可以在未安装npm的情况下使用npm库吗? [英] Can I use npm library without npm installed?

查看:114
本文介绍了我可以在未安装npm的情况下使用npm库吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发NodeJS应用程序。它将与Electron一起部署。这很好,因为我要做的就是将应用程序包装在Electron软件包内的app文件夹中,然后按照Electron官方文档中的说明将其重新命名,然后准备将其安装在任何计算机上。

I am developing a NodeJS application. It will be deployed with Electron. This is good because all I will need to do is to package my application in an app folder inside the Electron package, then rebrand it as described on the official Electron documentation, and I will be ready to install it on any computer.

特别是,使用Electron进行部署意味着我不需要在用户的计算机上安装NodeJS,因为Electron软件包本身就是NodeJS解释器,因此它将用完

In particular, deploying with Electron means that I don't need to have NodeJS installed on my user's computer, because the Electron package is itself a NodeJS interpreter so it is going to run out of the box completely on its own.

现在,当我在系统上安装NodeJS时,还同时安装了npm。这意味着每当我需要安装软件包时,都可以从命令行使用它。

Now, when I installed NodeJS on my system I also got npm installed along with it. Which means that whenever I need to install a package, I can just use it from command line.

现在,我需要部署的程序将使存储库保持同步和更新。通过在需要时从github中提取它。我为Git找到了一个很棒的NodeJS绑定,即nodegit,它可以独立工作,而无需在目标计算机上安装任何东西,这很好,因为我不确定用户是否会安装git。现在,每次我提取存储库时,我还需要进行一些 npm安装

Now, the program I need to deploy will keep a repository synced and updated by pulling it from github when needed. I found a wonderful NodeJS binding for Git, nodegit, that works on its own without any need of installing anything on the target computer, which is good because I am not sure my users will have git installed. Now, every time I pull my repository I will also need to do some npm install.

哪个会调出我的问题:我知道有一个库 npm ,可以从任何NodeJS程序中以编程方式使用npm。但是, npm 库是独立的东西还是取决于系统上 npm 的安装?如果是这样,我该如何解决此问题?我需要能够从部署在用户环境中无法假定已安装其他任何东西的电子应用程序中进行 npm安装,特别是npm。 / p>

Which brings up my question: I know that there is a library npm that I can use to use npm programmatically from any NodeJS program. However, is that npm library a standalone thing, or it depends on the installation of npm on the system? If so, how can I work around this problem? I need to be able to do an npm install from an Electron app deployed somewhere on an user environment that I can't assume to have anything else installed, npm in particular.

推荐答案

npm install-保存npm

不确定我为什么认为那行不通,但我对其进行了测试,而且似乎也:)

Not sure why I thought that wouldn't work, but I tested it and it seems too :)

这篇关于我可以在未安装npm的情况下使用npm库吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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