pnp / vscode-viva

With the SharePoint Framework Toolkit extension, you can create and manage your SharePoint Framework solutions on your tenant. All actions you need to perform during the development flow are at your fingertips.
https://marketplace.visualstudio.com/items?itemName=m365pnp.viva-connections-toolkit
MIT License
38 stars 16 forks source link

🐞 Bug report: Activating extension 'm365pnp.viva-connections-toolkit' failed: Cannot use import statement outside a module. #293

Closed maximkol closed 1 month ago

maximkol commented 1 month ago

⭐ Priority

(Low)☹️ Something is a little off

📝 Describe the bug

I've tried to follow contribution guide and run local version of extension. Latest step in guide is to press F5 to start extension. After that new VS Code window is opened, but extension is not loaded, and I see error "Activating extension 'm365pnp.viva-connections-toolkit' failed: Cannot use import statement outside a module. "

👣 Steps To Reproduce

Steps described here: https://github.com/pnp/vscode-viva/blob/main/contributing.md

📜 Expected behavior

Local version of extension is started for debugging

📷 Screenshots

image

❓SharePoint Framework Toolkit version

current dev branch

❓Node.js version

18.19.0

🤔 Additional context

m365 cli was cloned from https://github.com/Adam-it/cli-microsoft365/tree/cli-cjs npm install, npm run clean, npm run build was executed successfully in cli repo. script to copy local cli version is also executed successfully.

Any advice on what else I should check to provide additional information would be appreciated

Adam-it commented 1 month ago

hi. Thank you for trying to contribute to this product (You Rock 🤩) and sorry to hear you already have problem with that. The error message indicate you have a dependency which is in ESM not CJS. Currently there is no support in VS Code extensions that are build as js modules. I suspect you have build the CLI from Microsoft 365 from main branch which is the 'new' CLI which is in esm. in order to use CLI in cjs you need to change branch to cli-cjs and then run the build command npm install, npm run clean, npm run build. To change the branch to cli-cjs you may run the command git checkout cli-cjs when being in cli-microsoft365 repo folder.

After you switch to the correct branch and rebuild you will then need to again run the script that copies over CLI to SPFX toolkit and then run npm run watch and hit f5.

Let me know if it helped

maximkol commented 1 month ago

Hi @Adam-it , thanks for quick response! and yes, I just forget to switch the branch. It works now

Adam-it commented 1 month ago

Awesome, glad I got you unblocked 👍 Happy Coding!