我想要./../bin/<variable>.json
。所以我将var设为var (reqLink = "'./../bin/"+lanID+".json'")
并传递给(var engJason = require(reqLink))
,但它不起作用。但它确实适用于像(var engJason = require('./../bin/eng.json');)
var reqLink = "'./../bin/"+lanID+".json'";
var engJason = require(reqLink);
//Not working ||error Cannot find module ''./../bin/eng.json''
答案 0 :(得分:1)
删除额外的单引号:
"'./../bin/"+lanID+".json'"
=&gt; "./../bin/" + lanID + ".json"