0
可見我聲明瞭全局變量如下:全球聲明的變量是不是在其他模塊
var NODE_MODULES_PATH = process.env.NODE_PATH || 'C:/Users/../AppData/Roaming/npm/node_modules/';
global.NODE_PATH = NODE_MODULES_PATH;
,但是當我在其他模塊例如訪問它flollows:
var mysql = require(NODE_PATH + 'mysql');
它提供了以下錯誤:
ReferenceError: NODE_PATH is not defined
at Object.<anonymous> (z:\$app4pc\website_engine\conf\dbconnection.js:1:83)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (z:\$app4pc\website_engine\models\login_model.js:1:76)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
Process finished with exit code 1