我正在尝试使用角度2流星,我在服务器端使用FS等节点库时遇到了一些问题。
import fs from 'fs';
结果:
(3, 16): Cannot find module 'fs'.
20170625-07:41:23.740(3)? (STDERR) TypeError: Cannot read property 'readFile' of undefined
W20170625-07:41:23.740(3)? (STDERR) at meteorInstall.server.wordGraph.wordGraph.js (server/wordGraph/wordGraph.ts:8:3)
W20170625-07:41:23.740(3)? (STDERR) at fileEvaluate (packages\modules-runtime.js:333:9)
W20170625-07:41:23.741(3)? (STDERR) at require (packages\modules-runtime.js:228:16)
W20170625-07:41:23.741(3)? (STDERR) at server/main.ts:5:4
答案 0 :(得分:0)
使用Npm.require
代替
var fs = Npm.require('fs');