node.js - 需要子文件夹中的 node_module

标签 node.js node-modules

所以我有一些 node.js 文件

/folder/app.js
/folder/node_modules/moduleIwanttoload
/folder/subfolder/file.js

我如何从 file.js 请求 moduleIwanttoload

最佳答案

你可以在 app.js 中使用像这样的子文件夹文件

var file = require('./subfolder/file.js');

在 Node 模块的文件夹中,你可以像这样使用它

var moduleIwanttoload = require("moduleIwanttoload");

关于node.js - 需要子文件夹中的 node_module,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24854554/

相关文章:

javascript - Node 和 DialogFlow 错误 : UnhandledPromiseRejectionWarning: TypeError: sessionClient. projectAgentSessionPath 不是函数

javascript - 有没有办法在全局级别上从 webpack 中排除 node_modules ?

node.js - 如何在 nodejs 中使用 MaterializeCSS?

node.js 表达 __dirname 父路径出错

javascript - Sails.js 增量属性

javascript - TypeError : vue. openBlock 不是函数,同时使用自定义节点模块中的 vue 组件

javascript - 如何使用 Browserify 和 Gulp 启动多页面应用程序

Node.js 模块 : export async function

node.js - 与 Objection.js 的自引用多对多关系

node.js - npm install bcrypt - 在 Windows 7 上没有错误,但有大量警告