gpt4 book ai didi

javascript - MeteorJS + npm : Cannot find module 'node-xmpp'

转载 作者:太空宇宙 更新时间:2023-11-04 02:34:06 25 4
gpt4 key购买 nike

我在 http://meteorhacks.com/complete-npm-integration-for-meteor.html 上遵循了本指南关于如何将 npm 包与meteor 一起使用。现在我有了这个

packages.json

{
"node-xmpp": "0.10.0"
}

服务器.js

var xmpp = Npm.require('node-xmpp');

.meteor/包

standard-app-packages
accounts-ui
accounts-github
insecure
accounts-base
accounts-password
npm

但是当我运行服务器时我不断收到此消息W20

140608-11:58:32.132(-4)? (STDERR) Error: Cannot find module 'node-xmpp'
W20140608-11:58:32.132(-4)? (STDERR) at Function.Module._resolveFilename (module.js:338:15)
W20140608-11:58:32.132(-4)? (STDERR) at Function.Module._load (module.js:280:25)
W20140608-11:58:32.132(-4)? (STDERR) at Module.require (module.js:364:17)
W20140608-11:58:32.132(-4)? (STDERR) at require (module.js:380:17)

有什么想法吗?

@ChristianFritz,从应用程序的根目录运行 npm install node-xmpp 会创建\node_modules。当我运行服务器时, meteor 爆炸,因为它认为它们是常规应用程序文件。

=> Errors prevented startup:

While building the application:
node_modules/node-xmpp/node_modules/browserify/node_modules/insert-module-globals/node_modules/browserify/node_modules/insert-module-globals/node_modules/lexical-scope/node_modules/astw/node_modules/esprima-six/demo/collector.html:1: Can't set DOCTYPE here. (Meteor sets <!DOCTYPE html> for you)

最佳答案

使用 Meteor.require() 而不是 Npm.require()。

var xmpp = Meteor.require('node-xmpp');

在 npm 包文档 ( http://meteorhacks.com/complete-npm-integration-for-meteor.html ) 中找到的说明:

Normally you are loading core npm modules using Npm.require(), But in order to load modules from your packages.json you need to use Meteor.require()

关于javascript - MeteorJS + npm : Cannot find module 'node-xmpp' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24108220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com