cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

m365 : The term 'm365' is not recognized as the name of a cmdletBug

Open nicetohaveyou opened this issue 1 year ago • 9 comments

Description

PS C:\POC\react-teams-lead-dashboard> npm i -g @pnp/cli-microsoft365 C:\Program Files (x86)\Nodist\bin\microsoft365 -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\index.js C:\Program Files (x86)\Nodist\bin\m365 -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\index.js C:\Program Files (x86)\Nodist\bin\m365_comp -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\autocomplete.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules@pnp\cli-microsoft365\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

  • @pnp/[email protected] updated 1 package in 5.09s PS C:\POC\react-teams-lead-dashboard> m365 m365 : The term 'm365' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
  • m365
  •   + CategoryInfo          : ObjectNotFound: (m365:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

PS C:\POC\react-teams-lead-dashboard> ls

Directory: C:\POC\react-teams-lead-dashboard

Mode LastWriteTime Length Name


d----- 05/08/2022 22:38 .devcontainer d----- 05/08/2022 22:38 assets d----- 05/08/2022 22:38 config d----- 05/08/2022 22:57 dist d----- 05/08/2022 22:42 lib d----- 05/08/2022 22:41 node_modules d----- 05/08/2022 22:43 release d----- 05/08/2022 22:43 sharepoint d----- 05/08/2022 22:38 src d----- 05/08/2022 22:38 teams d----- 05/08/2022 22:57 temp -a---- 05/08/2022 22:38 334 .gitignore -a---- 05/08/2022 22:38 312 .yo-rc.json -a---- 05/08/2022 22:38 407 gulpfile.js -a---- 05/08/2022 22:41 913882 package-lock.json -a---- 05/08/2022 22:38 1242 package.json -a---- 05/08/2022 22:38 4584 README.md -a---- 05/08/2022 22:38 772 tsconfig.json -a---- 05/08/2022 22:38 826 tslint.json

PS C:\POC\react-teams-lead-dashboard>

Steps to reproduce

PS C:\POC\react-teams-lead-dashboard> npm i -g @pnp/cli-microsoft365 C:\Program Files (x86)\Nodist\bin\microsoft365 -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\index.js C:\Program Files (x86)\Nodist\bin\m365 -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\index.js C:\Program Files (x86)\Nodist\bin\m365_comp -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\autocomplete.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules@pnp\cli-microsoft365\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

  • @pnp/[email protected] updated 1 package in 5.09s PS C:\POC\react-teams-lead-dashboard> m365 m365 : The term 'm365' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
  • m365
  •   + CategoryInfo          : ObjectNotFound: (m365:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    
    

Expected results

i dont know what expected results are i dont see any.

Actual results

PS C:\POC\react-teams-lead-dashboard> npm i -g @pnp/cli-microsoft365 C:\Program Files (x86)\Nodist\bin\microsoft365 -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\index.js C:\Program Files (x86)\Nodist\bin\m365 -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\index.js C:\Program Files (x86)\Nodist\bin\m365_comp -> C:\Program Files (x86)\Nodist\bin\node_modules@pnp\cli-microsoft365\dist\autocomplete.js npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules@pnp\cli-microsoft365\node_modules\fsevents): npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

  • @pnp/[email protected] updated 1 package in 5.09s PS C:\POC\react-teams-lead-dashboard> m365 m365 : The term 'm365' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
  • m365
  •   + CategoryInfo          : ObjectNotFound: (m365:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

PS C:\POC\react-teams-lead-dashboard> ls

Directory: C:\POC\react-teams-lead-dashboard

Mode LastWriteTime Length Name


d----- 05/08/2022 22:38 .devcontainer d----- 05/08/2022 22:38 assets d----- 05/08/2022 22:38 config d----- 05/08/2022 22:57 dist d----- 05/08/2022 22:42 lib d----- 05/08/2022 22:41 node_modules d----- 05/08/2022 22:43 release d----- 05/08/2022 22:43 sharepoint d----- 05/08/2022 22:38 src d----- 05/08/2022 22:38 teams d----- 05/08/2022 22:57 temp -a---- 05/08/2022 22:38 334 .gitignore -a---- 05/08/2022 22:38 312 .yo-rc.json -a---- 05/08/2022 22:38 407 gulpfile.js -a---- 05/08/2022 22:41 913882 package-lock.json -a---- 05/08/2022 22:38 1242 package.json -a---- 05/08/2022 22:38 4584 README.md -a---- 05/08/2022 22:38 772 tsconfig.json -a---- 05/08/2022 22:38 826 tslint.json

PS C:\POC\react-teams-lead-dashboard>

Diagnostics

m365 m365 : The term 'm365' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • m365
  •   + CategoryInfo          : ObjectNotFound: (m365:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

CLI for Microsoft 365 version

no version

nodejs version

V14.15.0

Operating system (environment)

Windows

Shell

PowerShell

cli doctor

PS C:\POC\react-teams-lead-dashboard> cli doctor cli : Cannot find path 'C:\POC\react-teams-lead-dashboard\doctor' because it does not exist. At line:1 char:1

  • cli doctor
  •   + CategoryInfo          : ObjectNotFound: (C:\POC\react-teams-lead-dashboard\doctor:String) [Clear-Item], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ClearItemCommand
    
    

Additional Info

PS C:\POC\react-teams-lead-dashboard> cli doctor cli : Cannot find path 'C:\POC\react-teams-lead-dashboard\doctor' because it does not exist. At line:1 char:1

  • cli doctor
  •   + CategoryInfo          : ObjectNotFound: (C:\POC\react-teams-lead-dashboard\doctor:String) [Clear-Item], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.ClearItemCommand
    

nicetohaveyou avatar Aug 07 '22 15:08 nicetohaveyou

Hi @nicetohaveyou,

Thanks for reaching out to us!

Question: I see a slightly irregular nodejs folder (C:\Program Files (x86)\Nodist\bin) Could you verify that it is included in your PATH variable. That's probably the reason the m365 command does not resolve to its executable.

martinlingstuyl avatar Aug 07 '22 18:08 martinlingstuyl

Hi @martinlingstuyl,

I am also getting the same error. I am trying to create CD pipeline in Azure DevOps to deploy sppkg to SharePoint. I was getting error "The system cannot find the file specified." when running task to login to Sharepoint.

When I tried to login using m365 cli on one of my VM I was getting the same error:

m365 login --authType password --userName [email protected] --password ***
The system cannot find the file specified.

When I ran "npm view @pnp/cli-microsoft365" to check details on m365 CLI, I got below output:

C:\Users\User>npm view @pnp/cli-microsoft365

@pnp/[email protected] | MIT | deps: 24 | versions: 488
Manage Microsoft 365 and SharePoint Framework projects on any platform
https://pnp.github.io/cli-microsoft365/

keywords: office 365, microsoft 365, sharepoint framework, o365, m365, spfx, sha
repoint online, sharepoint, microsoft teams, microsoft graph, microsoft flow, az
ure active directory, azure ad, azure, microsoft

bin: m365, m365_comp, microsoft365

But When I run "m365 version" I'm getting below error:

C:\Windows\system32>m365 version
'm365' is not recognized as an internal or external command,
operable program or batch file.

Nodejs path(C:\Program Files\nodejs) was already included in PATH variable.

nodejs version: V14.15.0 Operating system: Windows Shell: PowerShell

AkashSatoliya avatar Aug 23 '22 08:08 AkashSatoliya

Hi @nicetohaveyou,

Can I assume your problem is solved? If so I can close this issue.

Please let us know 👍

martinlingstuyl avatar Aug 23 '22 16:08 martinlingstuyl

Closing this issue in favor of #3612

waldekmastykarz avatar Aug 24 '22 10:08 waldekmastykarz

i want to know why this issue was closed, when there was no resolution. I have ran it from the docker yet face the issue. It is not resolved.

nicetohaveyou avatar Aug 24 '22 11:08 nicetohaveyou

Ah sorry, that's my bad, due to the other question that was asked in between.

I believe a while back @martinlingstuyl asked you for more information here: https://github.com/pnp/cli-microsoft365/issues/3565#issuecomment-1207457556. Could you please double check your $PATH variable to verify that Node is in there?

waldekmastykarz avatar Aug 24 '22 12:08 waldekmastykarz

Do i need to worry about the $PATH when it is been run from the docker where the environment is already configured?

nicetohaveyou avatar Aug 25 '22 23:08 nicetohaveyou

If the command cannot be found, the reason must be that it is either not installed or is not on your PATH.

Are you in a PowerShell terminal? You can check where the global packages are being installed and verify whether they are on your path as follows:

npm root -g

Write-Host $env:path

If the directory is not in the PATH, you should update the PATH.

martinlingstuyl avatar Aug 26 '22 05:08 martinlingstuyl

@nicetohaveyou did you have a chance to look at @martinlingstuyl suggestion?

waldekmastykarz avatar Sep 05 '22 17:09 waldekmastykarz

Closing due to lack of response

waldekmastykarz avatar Oct 09 '22 10:10 waldekmastykarz

I am having the same problem.

my typical set up is to run Windows Sandbox (from Windows 10) and then in the Windows PowerShell, issue the following commands:

Set-ExecutionPolicy Bypass -Scope Process -Force; 
iex "& {$(irm get.scoop.sh)} -RunAsAdmin"
scoop install nvs
nvs add lts
nvs use lts
npm install @pnp/cli-microsoft365
m365 version

The output I am getting is:

PS C:\Users\WDAGUtilityAccount> npm install @pnp/cli-microsoft365

up to date, audited 519 packages in 4s

31 packages are looking for funding
  run `npm fund` for details

6 vulnerabilities (5 moderate, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.
PS C:\Users\WDAGUtilityAccount> m365 version
m365 : The term 'm365' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ m365 version
+ ~~~~
    + CategoryInfo          : ObjectNotFound: (m365:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\WDAGUtilityAccount> npm audit fix
npm ERR! code EBADPLATFORM
npm ERR! notsup Unsupported platform for [email protected]: wanted {"os":"darwin"} (current: {"os":"win32","arch":"x64"})
npm ERR! notsup Valid OS:    darwin
npm ERR! notsup Valid Arch:  undefined
npm ERR! notsup Actual OS:   win32
npm ERR! notsup Actual Arch: x64

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\WDAGUtilityAccount\AppData\Local\npm-cache\_logs\2022-10-19T14_13_55_982Z-debug-0.log

As requested:

PS C:\Users\WDAGUtilityAccount> npm root -g
C:\Users\WDAGUtilityAccount\scoop\apps\nvs\current\nodejs\node\16.18.0\x64\node_modules
PS C:\Users\WDAGUtilityAccount> Write-Host $env:path
C:\Users\WDAGUtilityAccount\scoop\apps\nvs\current\nodejs\node\16.18.0\x64;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\WDAGUtilityAccount\scoop\apps\nvs\current;C:\Users\WDAGUtilityAccount\scoop\shims;C:\Users\WDAGUtilityAccount\AppData\Local\Microsoft\WindowsApps

It seems that the problem is related to fsevents. This appears to be a Mac only thing but for some reason this project is trying to install it even on Windows?

It worked for me as recently as a few days ago, so maybe something has changed? m365 cli

29039 avatar Oct 19 '22 14:10 29039

As an update, I went back to using npm install -g @pnp/cli-microsoft365 (with the -g) and it seems to install now. Typically I try to keep these commands relatively portable to be able to run as a standard user if need be, but somewhere along the line, \node_modules.bin has gone missing from the path.

29039 avatar Oct 19 '22 15:10 29039

Hi @29039, yeah you have to be very careful that the node_modules/.bin folder is on your Path.

What you can do is add it to your path (within the ps session) from within your script, using [System.Environment]::SetEnvironmentVariable()

martinlingstuyl avatar Oct 19 '22 16:10 martinlingstuyl