节点:找不到通用模块

时间:2018-10-11 08:21:55

标签: node.js commonjs

我正在运行没有任何问题的节点服务器,出于某种目的,必须删除node_modules目录并重新安装依赖项。这样做并再次运行服务器后,出现此错误:

Error: Cannot find module './common'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\Work\Cinde-Node\node_modules\debug\src\node.js:236:18)
    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)

我使用common分别安装了npm install common,但这并不能解决问题。

该如何解决?

1 个答案:

答案 0 :(得分:1)

好像你有一条线 function mergeSheets() { var folders = DriveApp.getFolders(); while (folders.hasNext()) { var folder = folders.next(); Logger.log(folder.getName()); } var spreadSheets = folder.getFilesByType("application/vnd.google- apps.spreadsheet"); while (spreadSheets.hasNext()) { var sheet = spreadSheets.next(); var spreadSheet = SpreadsheetApp.openById(sheet.getId()); for (var y in spreadSheet.getSheets()) { spreadSheet.getSheets()[y].copyTo(newSpreadSheet); } } } function onOpen() { var spreadsheet = SpreadsheetApp.getActive(); var menuItems = [ { name: 'Merge Release Sheets', functionName: 'mergeSheets' } ]; spreadsheet.addMenu('MergePackages', menuItems); } 它应该是 require('./common');