Closed lifeofdave closed 10 months ago
By default for CommonJs projects, Quokka uses esm module for JavaScript files, and it may function slightly differently from standard node loading mechanism (depending on the used node version). There are a couple of ways to make this work as expected:
esm
module by adding "stdEsm": false,
to your Quokka config file. You may disable it for all projects, or, if you don't want to disable it for all projects, you may use .quokka
file or modify package.json
to only disable it for this specific project.-const axios = require('axios');
+const axios = require('axios').default;
and it will work is both node and Quokka.
amazing, thanks for quick reply
Issue description or question
When importing axios using require I get a
Error: TypeError: axios.request is not a function
error. The code runs fine when using node.js. Any way round this? For context I'm developing to deploy to Azure functions - hence use of require.Sample code
Quokka.js Console Output
Code editor version
Visual Studio Code v1.85.1
OS name and version
OSX
Quokka version
v1.0.609