【发布时间】:2018-11-15 23:08:06
【问题描述】:
我们正在 Nodejs 中创建一个模块,我们想在用户文件夹 (Windows) 中读取一个 JSON 文件,但系统 var "%userprofile%" 无法使用 fs.readfilesync 函数。
var fs = require('fs');
var myConfig = JSON.parse(fs.readFileSync('%userprofile%/manager-cli.json', 'utf8'));
错误:
Error: ENOENT: no such file or directory, open 'C:\angular\manager-cli\%userprofile%\manager-cli.json'
有人知道问题的解决方案吗?或替代方案。
来源:https://github.com/jserra91/manager-cli/blob/master/bin/global.js
谢谢。
【问题讨论】:
标签: javascript node.js