Reputation: 53
After successfully running grunt concat to concatnate all my node js files into a single file, I get an error when running the file using "$node bundle.js", saying that it cannot find module "./config.js"
In original file: var config = require('./config.js'); // do something with config.
In bundle file, it pastes config.js's contents into the bundle file, and then does "var config = require('./config.js);
But obviously this isn't going to be in the same location... isn't concat supposed to put all modules into the same file?
Am I using concat with grunt wrong?
Upvotes: 0
Views: 291
Reputation: 13273
You should not be concatenating Node files! This is not how node (and require()
) works. We only concatenate JavaScript files intended for the browser in order to minimize page load time by reducing the number of HTTP requests.
So the answer is: do not concatenate Node JS files!
Upvotes: 0