如何在不使用 npm 的情况下安装 node.js 模块? [英] How to install a node.js module without using npm?

查看:63
本文介绍了如何在不使用 npm 的情况下安装 node.js 模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 node 的 github 页面 上列出了很多模块与 npm-registry 一起发布.这些模块不能使用 npm 安装.

There are quite a few modules which are listed on node's github page but are not published with the npm-registry. These modules can't be installed using npm.

从 Git 克隆后安装这些 nodejs 模块的正确方法是什么?

What is the correct way to install these nodejs modules after cloning them from Git?

推荐答案

你需要从github下载他们的源码.找到主文件,然后将其包含在主文件中.

You need to download their source from the github. Find the main file and then include it in your main file.

可以在此处找到一个示例 > 如何手动安装节点.js 模块?

An example of this can be found here > How to manually install a node.js module?

通常你需要找到源并浏览 package.json 文件.在那里你可以找到哪个是主文件.这样您就可以将其包含在您的应用程序中.

Usually you need to find the source and go through the package.json file. There you can find which is the main file. So that you can include that in your application.

在您的应用中包含 example.js.将其复制到您的应用程序文件夹中,并将其附加到您的主 js 文件的顶部.

To include example.js in your app. Copy it in your application folder and append this on the top of your main js file.

var moduleName = require("path/to/example.js")

这篇关于如何在不使用 npm 的情况下安装 node.js 模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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