从一个新鲜的meteor create
项目,以下适用于我。
在/server/main.js
:
import { Meteor } from 'meteor/meteor';
Meteor.startup(() => {
// code to run on server at startup
});
import net from 'net';
export class Print {
printAsync(callback){
let client = new net.Socket();
console.log(client);
}
}
console.log(net);
const print = new Print();
print.printAsync();
输出在控制台:
I20161129-07:59:18.007(-8)? { createServer: [Function],
I20161129-07:59:18.008(-8)? createConnection: [Function],
I20161129-07:59:18.008(-8)? connect: [Function],
I20161129-07:59:18.008(-8)? _normalizeConnectArgs: [Function: normalizeConnectArgs],
I20161129-07:59:18.008(-8)? Socket: { [Function: Socket] super_: { [Function: Duplex] super_: [Object] } },
I20161129-07:59:18.008(-8)? Stream: { [Function: Socket] super_: { [Function: Duplex] super_: [Object] } },
I20161129-07:59:18.009(-8)? Server:
I20161129-07:59:18.009(-8)? { [Function: Server]
[...]
I20161129-07:59:18.012(-8)? Socket {
I20161129-07:59:18.013(-8)? _connecting: false,
I20161129-07:59:18.013(-8)? _hadError: false,
I20161129-07:59:18.013(-8)? _handle: null,
I20161129-07:59:18.013(-8)? _parent: null,
I20161129-07:59:18.013(-8)? _host: null,
I20161129-07:59:18.013(-8)? _readableState:
I20161129-07:59:18.020(-8)? ReadableState {
I20161129-07:59:18.020(-8)? objectMode: false,
I20161129-07:59:18.020(-8)? highWaterMark: 16384,
[...]
我无法重现您不确定net
。
我正在导入它在服务器端,但导入不起作用。 –
呵呵,它适合我。你有样品回购还是你能提供更多的上下文? – kooc
我更新了问题。变量网络是未定义的。你是如何导入网络模块的?你安装了npm包吗? –