Javascript Npm.require can';找不到节点模块
我一直在尝试使用Javascript Npm.require can';找不到节点模块,javascript,node.js,meteor,Javascript,Node.js,Meteor,我一直在尝试使用Npm.require获取ldapjs模块并将其用于客户端身份验证,但是我收到以下消息 var ldap = Npm.require('ldapjs'); Error: Cannot find module 'ldapjs' require不是应该从npm下载包吗 不,不是Meteor将只下载节点模块,只要它在智能包中声明,并使用Npm.depends({…})指令。如果您的代码不是某个智能包的一部分,则需要手动安装节点模块。不,不是Meteor将只下载节点模块,只要它在
Npm.require
获取ldapjs
模块并将其用于客户端身份验证,但是我收到以下消息
var ldap = Npm.require('ldapjs');
Error: Cannot find module 'ldapjs'
require
不是应该从npm下载包吗 不,不是Meteor将只下载节点模块,只要它在智能包中声明,并使用Npm.depends({…})
指令。如果您的代码不是某个智能包的一部分,则需要手动安装节点模块。不,不是Meteor将只下载节点模块,只要它在智能包中声明,并使用Npm.depends({…})
指令。如果您的代码不是某些智能软件包的一部分,则需要手动安装节点模块。在Meteor软件包中使用npm模块需要两件事:
{
"ldapjs": "0.6.3"
}
例如,查看Meteor中的包。其package.js指定依赖于npm模块cli颜色,其logging.js文件需要并使用该模块。在Meteor软件包中使用npm模块需要两件事:
{
"ldapjs": "0.6.3"
}
例如,查看Meteor中的包。其package.js指定依赖于npm模块cli颜色,其logging.js文件需要并使用该模块。目前在Meteor中使用npm包的最佳方式是。关于如何使用它的说明非常清楚。基本上,你要做三件事: 1) 安装npm:
mrt add npm
2) 创建包含所需包列表的packages.json
文件:
{
"ldapjs": "0.6.3"
}
3) 通过Meteor使用软件包。要求:
var ldapjs = Meteor.require('ldapjs');
目前在Meteor中使用NPM包的最佳方法是。关于如何使用它的说明非常清楚。基本上,你要做三件事: 1) 安装npm:
mrt add npm
2) 创建包含所需包列表的packages.json
文件:
{
"ldapjs": "0.6.3"
}
3) 通过Meteor使用软件包。要求:
var ldapjs = Meteor.require('ldapjs');
主应用程序中的节点模块
如果要从主应用程序使用npm,该怎么办?如果您不想手动安装节点模块(一个维护难题),该怎么办
这是可能的解决办法。创建垫片智能包,为主应用程序提供节点模块。将模块导出到主应用程序
确切的步骤
1。在Meteor应用程序外部创建一个目录npm shim
。我们将在步骤3中使用它
2.将这两个文件添加到其中: 文件
package.js
// npm dependencies are only available for packages. If you have npm
// dependencies for the main application, you need this workaround:
// Create a shim package to provide the npm dependencies to the main app.
Package.describe({
summary: "Meteor main application npm dependencies"
});
Npm.depends({
colors: '0.6.2',
// Add more modules as needed.
});
Package.on_use(function(api) {
api.export("NpmShim"); // Omit this for versions before 0.6.5
api.add_files("npm.js", "server");
});
NpmShim = {};
NpmShim.colors = Npm.require('colors');
// Add more modules as needed.
文件npm.js
// npm dependencies are only available for packages. If you have npm
// dependencies for the main application, you need this workaround:
// Create a shim package to provide the npm dependencies to the main app.
Package.describe({
summary: "Meteor main application npm dependencies"
});
Npm.depends({
colors: '0.6.2',
// Add more modules as needed.
});
Package.on_use(function(api) {
api.export("NpmShim"); // Omit this for versions before 0.6.5
api.add_files("npm.js", "server");
});
NpmShim = {};
NpmShim.colors = Npm.require('colors');
// Add more modules as needed.
3.编辑smart.json并添加此行:
"npm-shim": { "path": <path to the directory created in step 1> },
“npm垫片”:{“路径”:},
4.执行
mrt更新
然后meteor添加npm垫片
此解决方案的结果
节点模块可以从Meteor主应用程序使用,无需手动安装。使用NpmShim.colors
代替Npm.require('colors')
如果需要更多模块,则必须将它们添加到package.js
和npm.js
(请参见注释//根据需要添加更多模块
)。主应用程序中的节点模块
如果要从主应用程序使用npm,该怎么办?如果您不想手动安装节点模块(一个维护难题),该怎么办
这是可能的解决办法。创建垫片智能包,为主应用程序提供节点模块。将模块导出到主应用程序
确切的步骤
1。在Meteor应用程序外部创建一个目录npm shim
。我们将在步骤3中使用它
2.将这两个文件添加到其中: 文件
package.js
// npm dependencies are only available for packages. If you have npm
// dependencies for the main application, you need this workaround:
// Create a shim package to provide the npm dependencies to the main app.
Package.describe({
summary: "Meteor main application npm dependencies"
});
Npm.depends({
colors: '0.6.2',
// Add more modules as needed.
});
Package.on_use(function(api) {
api.export("NpmShim"); // Omit this for versions before 0.6.5
api.add_files("npm.js", "server");
});
NpmShim = {};
NpmShim.colors = Npm.require('colors');
// Add more modules as needed.
文件npm.js
// npm dependencies are only available for packages. If you have npm
// dependencies for the main application, you need this workaround:
// Create a shim package to provide the npm dependencies to the main app.
Package.describe({
summary: "Meteor main application npm dependencies"
});
Npm.depends({
colors: '0.6.2',
// Add more modules as needed.
});
Package.on_use(function(api) {
api.export("NpmShim"); // Omit this for versions before 0.6.5
api.add_files("npm.js", "server");
});
NpmShim = {};
NpmShim.colors = Npm.require('colors');
// Add more modules as needed.
3.编辑smart.json并添加此行:
"npm-shim": { "path": <path to the directory created in step 1> },
“npm垫片”:{“路径”:},
4.执行
mrt更新
然后meteor添加npm垫片
此解决方案的结果
节点模块可以从Meteor主应用程序使用,无需手动安装。使用NpmShim.colors
代替Npm.require('colors')
如果您需要更多模块,您必须将它们添加到
package.js
和npm.js
(请参见注释//根据需要添加更多模块)。回答得不错!我现在正在尝试,但是捷运要花很长时间(我支持一个代理,所以最后我不得不使用:npm安装-g meteor npm
meteor npm
回答得很好!我现在正在尝试,但是MRT需要永远……:(我支持一个代理,所以最后我不得不使用:npm安装-g meteor npm
meteor npm