我正在使用node.js上的hercule和hercule包来转换一些纯文本文件。 在Unix上,一切似乎都很好。 但是,有些同事在Windows上运行时遇到问题。 只有在Windows上运行时才会收到以下错误消息:
[13:02:01] TypeError: Cannot read property 'toString' of null at Object.transcludeStringSync (D:projectnode_modulesherculelibhercule.js:136:36)
我已经用[email protected]以及[email protected]尝试上面的[email protected] ,并且这两个包都给出了上面的错误。 但是,鉴于这只发生在Windows上,并在许多版本的软件包,我怀疑这个问题有什么应该由于Node.js安装或path 。
使用hercule包的代码:
var fs = require('fs'); var path = require('path'); var gulp = require('gulp'); var drakov = require('drakov'); var hercule = require('hercule'); gulp.task('mock',['i18n','build_minify_no_tests'],function() { var mockSpecificationTemplate= fs.readFileSync('test/mock/mock-template.apib','utf8'); var transcludedMockSpecification = hercule.transcludeStringSync(mockSpecificationTemplate,{ relativePath: path.resolve('../../../') }); fs.writeFileSync('test/mock/mock.apib',transcludedMockSpecification,'utf-8'); // Running mock server var drakovArgv = { sourceFiles: 'test/mock/mock.apib',serverPort: 9000,staticPaths: [ '../../' ],discover: true,watch: true }; drakov.run(drakovArgv); });
node和npm版本信息:
如何在Ubuntu上安装和构buildOpenSSL 1.0.0?
多个sqlite安装在同一台服务器上
在32位Windows 10上的Tensorflow:在这个平台上不是支持的轮子; 在当前的win-32频道丢失包,没有匹配的分配
为node.js v.0.8configuration文件丢失
$ node -v v6.3.0 $ npm -v 3.10.3
为应用程序select合适的文件扩展名
包libsndfile-dev没有安装候选
安装和注册win32 OpenSSL库
python3 PyQt / PySide Linux安装
hercule.transcludeStringSync只运行另一个hercule进程,并向其发送输入:
const result = childProcess.spawnSync('../bin/hercule',syncArgs,syncoptions);
用脚本../bin/hercule :
#!/usr/bin/env node "use strict"; require('../lib/main.js');
…显然不适用于Windows
如果该任务必须同步,则可以使用以下函数:
function transcludeStringSync(input,options) { const {dirname,join} = require('path') const hercule = join(dirname(require.resolve('hercule')),'main') const args = [hercule,'--reporter','json-err'] for (let name in options) { args.push(`--${name}`,`--${options[name]}`) } const result = require('child_process').spawnSync('node',args,{input}) const err = result.stderr.toString() if (err) throw new Error('Could not transclude input') return result.stdout.toString() }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。