未定义ReferenceError包含

时间:2018-08-07 06:58:42

标签: javascript angularjs node.js

 var number= include('dir1/dir2/SqlQueryMailNotification.js');

错误

ReferenceError: include is not defined
    at Object.<anonymous> (D:\Projects\metrix\source-code\MeTRIX_Next Gen Server\lib\notificationMail.js:2:17)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (D:\Projects\metrix\source-code\MeTRIX_Next Gen Server\server.js:9:24)
    at Module._compile (module.js:652:30)

1 个答案:

答案 0 :(得分:1)

include()既不是有效的ES6也不是有效的Node.js函数。您必须这样做:

var number = require('dir1/dir2/SqlQueryMailNotification.js');