CloudShell icon indicating copy to clipboard operation
CloudShell copied to clipboard

[BUG] Loading the Microsoft 365 CLI in Azure Cloud Shell

Open appieschot opened this issue 3 years ago • 9 comments

To Reproduce

Start up the CLI in either Bash or PS

m365 -v

Observed Behavior

username@Azure:~$ m365 -v
/usr/local/lib/node_modules/@pnp/cli-microsoft365/node_modules/webidl-conversions/lib/index.js:357
    } catch {
            ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at Module.patchedRequire [as require] (/usr/local/lib/node_modules/@pnp/cli-microsoft365/node_modules/diagnostic-channel/dist/src/patchRequire.js:14:46)
    at require (internal/module.js:11:18)

Expected behavior

Returning the version of the Microsoft 365 CLI that is available in the Shell

Is this specific to Cloud Shell?

Not quite sure, the Microsoft 365 CLI is working on other platforms so it looks like it is related to the recent changes in the base image.

Interface information

How are you accessing Cloud Shell - https://shell.azure.com, https://portal.azure.com, via Windows Terminal, or some other method? The error occurs in all scenarios (shell, portal and Windows terminal). Browser is Edge Dev latest release on Windows Version 10.0.19042. Windows Terminal Version: 1.4.3243.0

Additional context

N/a

appieschot avatar Dec 14 '20 20:12 appieschot

Pondering a bit on the issue it might be related to the node version (v8.16.0) in the base image, any change we could bump that to LTS? Or would that be something more suited for a discussion?

appieschot avatar Dec 14 '20 20:12 appieschot

I think your diagnosis is right - m365 has raised required node version above the rather old version we include. Updating node is the correct fix. Because node is also used to implement the app which connects the container to the browser, we have to check fairly carefully that nothing will break when we update it. I will look at that in the new year.

edyoung avatar Dec 16 '20 19:12 edyoung

@edyoung

Appreciate that this may not be on a priority list, however is it possible to give us an idea on whether this it is in your short term plans to update the node version in Azure Shell to LTS?

We would love to continue to promote the use of Azure Shell with the CLI for Microsoft 365 target audience however in its current state this is not possible.

Let us know if you need any assistance from us, we will be more than happy to help 👍🏻

garrytrinder avatar Feb 04 '21 18:02 garrytrinder

While I would like to fix right away, realistically it is medium term. You can see the PR above. The main issue as mentioned is validating that the node app which connects Cloud Shell to the browser is not affected by node upgrade. This is somewhat complicated so will take some time. Unfortunately since that piece is not open source it's not easy to collaborate on.

edyoung avatar Feb 10 '21 06:02 edyoung

Thanks for the update @edyoung much appreciated 👍🏻

Not sure if this helps you at all, but one of our contributors has found a workaround by using nvm to install the LTS version of node in the Cloud Shell and all appears to be working fine.

https://github.com/pnp/cli-microsoft365/issues/2017#issuecomment-776484351

garrytrinder avatar Feb 14 '21 00:02 garrytrinder

Hey @edyoung, any update when we can expect #67 to be merged?

waldekmastykarz avatar Apr 27 '21 17:04 waldekmastykarz

Hey @edyoung . It is good that the PR is ready to be merged. Totally appreciate your effort on that.

Any timeline of which you can think on this so that we can leverage CLI for M365 scripts for one of our use case.

arjunumenon avatar Jun 05 '21 09:06 arjunumenon

Hi @edyoung, any updates on this? I see the PR is still open.

martinlingstuyl avatar May 20 '22 15:05 martinlingstuyl

Linked PR has been closed https://github.com/Azure/CloudShell/pull/67#issuecomment-1167650340

We are tracking this internally and these changes will happen when we move to CBL-Mariner: microsoft/CBL-Mariner

garrytrinder avatar Jun 28 '22 19:06 garrytrinder