Installed a node package via npm i resize-start-end -S'
.
This is the instruction provided by the package:
// ESM
import resizeStartEnd from 'resize-start-end';
// or CommonJS
const resizeStartEnd = require('resize-start-end');
I'm trying to include the package in a JS file in my hugo static directory. None of the above works (can't be found).
My js is located in static/src/js
and gulp will concat it into static/js
.
Advice appreciated.
From Hugo version 0.56 you can use Hugo mounts.
After module install (npm i your-module -S
)
Add to your config file (json format for example):
"module": {
"mounts": [
{
"source": "node_modules",
"target": "static/src/node_modules"
}
]
}
Then you can use in your scripts in src directory:
import * as yourModule from './node_modules/your-module/index.js'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With