I'm using npm v 5.7.1 on Mac High Sierra. I just installed this module
我在Mac High Sierra上使用npm v 5.7.1。我刚刚安装了这个模块
npm install ssl-root-cas
(for some reason, adding "-g" didn't work). Then i have this in my JS file
(由于某种原因,添加“-g”不起作用)。然后我在我的JS文件中有这个
require('ssl-root-cas')
.inject()
.addFile(fs.readFileSync(conf.root_cert));
However, upon executing the above code (specifically the "inject()" line), I get the error
但是,在执行上面的代码(特别是“inject()”行)时,我得到了错误
/Users/satishp/Documents/workspace/projA/node_modules/ssl-root-cas/ssl-root-cas.js:3637
var filepaths = filepath.split(/\//g);
^
TypeError: filepath.split is not a function
at Array.module.exports.rootCas.addFile (/Users/satishp/Documents/workspace/projA/node_modules/ssl-root-cas/ssl-root-cas.js:3637:28)
at Object.<anonymous> (/Users/satishp/Documents/workspace/projA/server.js:79:3)
at Module._compile (module.js:662:30)
at Object.Module._extensions..js (module.js:673:10)
at Module.load (module.js:575:32)
at tryModuleLoad (module.js:515:12)
at Function.Module._load (module.js:507:3)
at Function.Module.runMain (module.js:703:10)
at startup (bootstrap_node.js:193:16)
at bootstrap_node.js:660:3
I'm somewhat confused about how to proceed. How do I overcome this error?
我对如何继续感到有些困惑。我该如何克服这个错误?
1 个解决方案
#1
0
You just need to pass the file path for the addFile
function, no need to manually load the file content:
您只需要传递addFile函数的文件路径,无需手动加载文件内容:
require('ssl-root-cas')
.inject()
.addFile(conf.root_cert);
#1
0
You just need to pass the file path for the addFile
function, no need to manually load the file content:
您只需要传递addFile函数的文件路径,无需手动加载文件内容:
require('ssl-root-cas')
.inject()
.addFile(conf.root_cert);