I'm currently learning about NPM modules and have a very basic question. Let's say I have my package.json
file which looks like this:
{
"version": "1.0.0",
"main": "express.js",
"dependencies": {
"lodash": "^4.17.20",
}
}
In my express.js
file I can then require
and use lodash like this:
const _ = require('lodash');
const numbers = [1,2,3,4,5,6];
_.each(numbers, function (number, i){
console.log(number)
});
I now have two questions:
- How can I display this code in a basic HTML document instead of just the console?
- How can I require/use node modules in another js file? E.g. if I want to require
lodash
from another js file?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…