我正在使用我的快递应用程序第一次尝试使用browserify。我已在全球安装了browserify。我收到了主题中提到的错误。我看了好几遍,看起来都很正确。我想也许是浏览器和表达的东西。我的设置是
app.use(express.static(path.join(__dirname, 'public')));
我使用此命令安装browserify
browserify public/javascripts/main.js -o public/javascripts/bundle.js
我的目录结构是
root
---public
---javascripts
bundle.js
main.js
和我的ejs
<script src="javascripts/bundle.js"></script>
<script src="javascripts/main.js"></script>
这是200 ok。 而我的main.js包含行
let helper_functions = require('./library/helper_functions');
有没有我错过的东西。所有文档都指出这是你如何做到的。任何指导都非常赞赏。
更新:我只想澄清如果我在helper_function.js中导出了几个函数,可以这样做:
let helper_functions =
function strToNumberArray(str, separator = ',') {
// function stuff
}
// Function to convert string to an array then convert each element to a number
// ========================================================================================== //
function strToNumberArray(str, separator = ',') {
function stuff//
}
module.export = helperFunctions;