我试图找出是否有办法让节目应用程序更清晰。 我有很多模块要求,也许有一种方法可以从modules.js之类的其他js文件中包含它们?
var express = require('express');
var vision = require('node-cloud-vision-api');
var AWS = require('aws-sdk');
var multerS3 = require('multer-s3');
var toArray = require('json-to-array');
var sizeof = require('object-sizeof');
var _ = require('underscore');
var request = require('request');
var unique = require('array-unique');
var async = require("async");
var bodyParser = require('body-parser');
var chrono = require('chrono-node');
var fs = require('fs');
var path = require('path');
var pdf2img = require('pdf2img');
var Knwl = require("knwl.js");
var knwlInstance = new Knwl('english');
var remove = require('array-remove');
var Fuse = require('fuse.js');
Array.prototype.remove = require("array-remove-by-value");
var fuzzysearch = require('fuzzysearch');
var promise = require('promise');
var mysql = require('mysql');
var Occurrences = require('occurences');
var session = require('express-session');
var multer = require('multer'),
答案 0 :(得分:0)
但是如果你想保持你的应用程序的顶级清洁器:
制作modules.js文件。首先导入然后导出此文件中的模块。
你想在哪里使用某些模块使用解构来提取它们,即
var {module_name,...} = require(path_to / modules.js);