0
我想要一個方便的「節點外殼」來加載一些常用的模型,以便我可以與它們和數據庫進行交互。似乎node inspect app_shell.js
無法導入(require
)腳本,同時聲稱已這樣做。node debug/inspect require returns undefined
文件結構:
./test
app_shell.js
user.js
app_shell.js
內容:
console.log("Script loads useful models for manual interaction in shell.");
var User = require("./user");
debugger;
user.js
內容:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.User = {some: "user"};
運行app_shell.js與調試:
$ node inspect app_shell.js
< Debugger listening on ws://127.0.0.1:9229/5f48d8f1-a77b-4a1c-838e-7fb51a3b3337
< For help see https://nodejs.org/en/docs/inspector
< Debugger attached.
Break on start in app_shell.js:1
> 1 (function (exports, require, module, __filename, __dirname) { console.log("Script loads useful models for manual interaction in shell.");
2 var User = require("./user");
debug> repl
Press Ctrl + C to leave debug repl
> User
undefined
> User = require("./user");
undefined
> User
{ User: Object, __esModule: true }
必須有一些我微不足道的小事。