Closed ahernandez-iusup closed 1 month ago
Yes, you can using asynchronous imports, but you lose IntelliSense. I had this same issue with writing NodeJS based Azure Functions as the template provided by Microsoft is commonjs. It took me a bit of time to figure it out and I've shared the details about how to switch. After that the only work is in changing the imports and making sure they all import the file with a .js extension. The information about how to do Async Imports as well as convert a commonjs project to esmodeules is here if you decide to go in that direction: https://pnp.github.io/pnpjs/getting-started/#importing-nodejs-support
Thanks for your help. I've solved the problem.
I'm going to close this issue as answered. If you have further issues, please feel free to create a new issue and reference this one.
This issue is locked for inactivity or age. If you have a related issue please open a new issue and reference this one. Closed issues are not tracked.
What version of PnPjs library you are using
4.x
Minor Version Number
1
Target environment
NodeJS
Additional environment details
I'm creating an add-in for office/outlook and I in my project i'm using commonJS and requires to import libraries. I have seen that one of the requirements to use pnp is - Node Modules Supported: ESM Only - but I would like to know if there is any option to use requires instead of imports to use pnp. I already have done some tests with ES Modules and I know it works perfectly but to upload my add-in to Azure it complicates a lot to change the development of the project from commonJS to ES Modules. Thanks in advance
Question/Request
It is possible to use commonJS with pnp?
const { SPDefault } = require("@pnp/nodejs"); const { spfi } = require("@pnp/sp"); require("@pnp/graph/users"); require("@pnp/sp/webs"); const formurlencoded = require('form-urlencoded'); require("@pnp/sp/folders");