Third party modules for Excel Add-In gives an error
Hello,
I am trying to build an Excel add-in that pulls data from the web using OAuth2 for authorisation.
The following code is causing issues:
const { URLSearchParams } = require("url");
const https = require("https");
The error I am receiving:
Module not found: Error: Can't resolve 'https' in 'C:\Users\ChungMan\Documents\Nexar-Excel add in\nexar-excel-v1\src\taskpane'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }'
- install 'https-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "https": false }
This is very similar to another question here (https://learn.microsoft.com/en-us/answers/questions/1110724/using-third-party-node-modules-with-excel-js-add-i) answered by your service, which recommended switching the project to a shared runtime.
However, this has not solved my issue.
Other attempts include:
Adding the library to the project (npm install https
)
Adding the fallback as described in the error message in webpack.config.js
These have not changed the error I am receiving or solved my issue.
Thanks,
Chung