OfficeDev / TeamsFx

Developer tools for building Teams apps
Other
427 stars 164 forks source link

bug report: SPFx.SPFxScaffoldError #6663

Closed Anandks1993 closed 1 year ago

Anandks1993 commented 1 year ago

ENOENT: no such file or directory, rename ' ' -> ' '

stack: SPFxScaffoldError: ENOENT: no such file or directory, rename ' ' -> ' ' at Object.ScaffoldError ( :2:7594111) at scaffoldSPFx ( :2:6349545) at async SPFxTabCodeProvider.generate ( :2:6342102) at async SPFxTabCodeProvider. ( :2:6751043) at async SPFxTab.add ( :2:6703788) at async TeamsfxCore.create ( :2:6426535) at async TeamsfxCore. ( :2:6751043) at async FxCore.createProjectOld ( :2:7707678) at async exports.ProjectSettingsWriterMW ( :2:7892481) at async exports.ContextInjectorMW ( :2:7826741) at async exports.ErrorHandlerMW ( :2:7839739)

I am trying to create a new app to start exploring SPFx framework from teams toolkit, but every time I try to create one getting this error saying no such file or directory, rename.

ghost commented 1 year ago

Thank you for contacting us! Any issue or feedback from you is quite important to us. We will do our best to fully respond to your issue as soon as possible. Sometimes additional investigations may be needed, we will usually get back to you within 2 days by adding comments to this issue. Please stay tuned.

Anandks1993 commented 1 year ago

Untitled

OS: Windows 10 node version: 14.19.0 npm version: 6.14.16

Anandks1993 commented 1 year ago

image

Also samples page is not loading the samples at all, it was showing the samples few days back but all of a sudden it is not loading at all.

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, from the error logs, Teams Toolkit failed when it tries to rename the folder 'c:\users\xxx\TeamsApps\todo-app-spfx\todo-app-spfx' to 'c:\users\xxx\TeamsApps\todo-app-spfx\spfx'. Could you help check whether the folder 'c:\users\xxx\TeamsApps\todo-app-spfx\todo-app-spfx' exists when the error happens?

Anandks1993 commented 1 year ago

No, that folder doesn't exist when this error happens. This error happens I am trying to create a project from scratch. I will attach a GIF of how I am trying to create a project with SPFx below for you reference.

Note: I did uninstall, removed code folder and installed VS code again to check about this. Also I downgraded to version 1.72.2 and still the same issue persist.

spfx-flow-1

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, maybe I didn't make it clear enough. When you create SPFx project with our Teams Toolkit, we'll first run yeoman (yo @microsoft/sharepoint) to create SPFx solution under target folder (in your case, it's 'c:\users\xxx\TeamsApps\todo-app-spfx\todo-app-spfx') and then rename the folder to 'SPFx'. As it fails to find the directory when renaming, I wonder whether yeoman scaffolded the solution correctly. Could you help check whether the directory is created after you create fail?

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft Sure, At first when I try to create SPFx tab teams toolkit asks me the Framework for which I chose React and then it asks me the web part name, I gave helloworld and then it asks me the folder that will contain the project root folder for which I select D:\SPFx-Apps (At this point SPFx-Apps will be an empty folder) then it asks me the Application name so I gave test-app. Then it created a folder under SPFx-Apps named test-app and inside that I see 2 folders (.fx and templates) and then 2 files(.gitignore and package.json) and that's it I don't see another folder named test-app under test-app it gets failed at this point saying [SPFx.SPFxScaffoldError]: ENOENT: no such file or directory, rename 'd:\SPFx-Apps\test-app\test-app' -> 'd:\SPFx-Apps\test-app\SPFx'

image

So in short test-app directory is not created under test-app directory.

And below is the console logged under OUTPUT tab.


[2022-11-08T08:47:01.446Z] [Info] - [core] start task:getProjectConfigV3 
[2022-11-08T08:47:01.448Z] [Info] - [core] finish task:getProjectConfigV3 , time: 2 ms
[2022-11-08T08:47:01.555Z] [Info] - Teams Toolkit extension is now active!
[2022-11-08T08:47:01.624Z] [Info] - [core] start task:getProjectConfig 
[2022-11-08T08:47:01.624Z] [Info] - [core] finish task:getProjectConfig , time: 0 ms
[2022-11-08T08:47:01.625Z] [Info] - [core] start task:getProjectConfig 
[2022-11-08T08:47:01.625Z] [Info] - [core] finish task:getProjectConfig , time: 0 ms
[2022-11-08T08:47:01.626Z] [Info] - [core] start task:getProjectConfig 
[2022-11-08T08:47:01.626Z] [Info] - [core] finish task:getProjectConfig , time: 0 ms
[2022-11-08T08:47:03.122Z] [Info] - [core] start task:createProjectOld 
[2022-11-08T08:47:03.123Z] [Info] - execute [TeamsfxCore.create] start!
[2022-11-08T08:47:38.250Z] [Info] - execute [AppManifest.init] start!
[2022-11-08T08:47:38.279Z] [Info] - execute [AppManifest.init] success!
[2022-11-08T08:47:38.282Z] [Info] - execute [SPFxTabCodeProvider.generate] start!
[2022-11-08T08:47:42.401Z] [Info] - execute [SPFxTabCodeProvider.generate] failed!
[2022-11-08T08:47:42.402Z] [Info] - execute [TeamsfxCore.create] failed!
[2022-11-08T08:47:42.402Z] [Info] - [core] finish task:createProjectOld , time: 39280 ms
[2022-11-08T08:47:42.402Z] [Error] - code:SPFx.SPFxScaffoldError, message: ENOENT: no such file or directory, rename 'd:\SPFx-Apps\test-app\test-app' -> 'd:\SPFx-Apps\test-app\SPFx', stack: SPFxScaffoldError: ENOENT: no such file or directory, rename 'd:\SPFx-Apps\test-app\test-app' -> 'd:\SPFx-Apps\test-app\SPFx'
    at Object.ScaffoldError (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7594111)
    at scaffoldSPFx (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6349545)
    at async SPFxTabCodeProvider.generate (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6342102)
    at async SPFxTabCodeProvider.<anonymous> (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6751043)
    at async SPFxTab.add (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6703788)
    at async TeamsfxCore.create (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6426535)
    at async TeamsfxCore.<anonymous> (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6751043)
    at async FxCore.createProjectOld (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7707678)
    at async exports.ProjectSettingsWriterMW (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7892481)
    at async exports.ContextInjectorMW (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7826741)
    at async exports.ErrorHandlerMW (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7839739)
    at scaffoldSPFx (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6349545)
    at async SPFxTabCodeProvider.generate (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6342102)
    at async SPFxTabCodeProvider.<anonymous> (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6751043)
    at async SPFxTab.add (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6703788)
    at async TeamsfxCore.create (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6426535)
    at async TeamsfxCore.<anonymous> (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:6751043)
    at async FxCore.createProjectOld (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7707678)
    at async exports.ProjectSettingsWriterMW (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7892481)
    at async exports.ContextInjectorMW (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7826741)
    at async exports.ErrorHandlerMW (c:\Users\Anand KS\.vscode\extensions\teamsdevapp.ms-teams-vscode-extension-4.1.1\out\src\extension.js:2:7839739)
Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft Any updates regarding this issue?

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, sorry for late reply since I was busy working on the new release. From the source code, the SPFx solution should be created before this renaming happens. I'm not sure whether there's anything wrong with the yeoman scaffolding. Could you help check the following items? 1> Check whether yo executables exist under '.fx\bin\yo' or '.fx\bin\yo\node_modules.bin' 2> Check whether SharePoint yeoman generator(@microsoft/generator-sharepoint) installed under '.fx\bin\spGenerator' 3> Add yo executable to env PATH and try to run the following command under an empty folder. Check whether SPFx solution is scaffolded successfully(Replace and to actual value) yo <HOME>\.fx\bin\spGenerator\node_modules\@microsoft\generator-sharepoint\lib\generators\app\index.js --skip-install true --component-type webpart --component-name helloworld --environment spo --skip-feature-deployment true --is-domain-isolated false --framework react --solution-name <your_solution_name>

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft No problem.

1> There isn't bin folder under .fx folder, I can only see configs folder under .fx (Assuming you are asking folders under the newly generated folder via toolkit) 2> No as bin folder is not present. 3> As there is no bin folder I don't think I can run the command. (This one is a bit confusing for me as you have mentioned empty folder.)

Note: I have already installed yo as a global package and I could create new app from that but I wanted to create it from teams toolkit.

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, when creating SPFx project, we'll install the packages under /.fx for scaffolding. It's weird that you don't have it. Did you disable the prerequisite check in settings? You can search 'Preferences: Open settings(UI)' in command palette and check the following option: image

Anandks1993 commented 1 year ago

Hi @HuihuiWu-Microsoft , No, I haven't disabled that settings. I checked the settings you mentioned in vs code and that is in enabled state. I am attaching the screenshot of that settings.

image

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, sorry for late reply since I was busy working on the new release. From the source code, the SPFx solution should be created before this renaming happens. I'm not sure whether there's anything wrong with the yeoman scaffolding. Could you help check the following items? 1> Check whether yo executables exist under '.fx\bin\yo' or '.fx\bin\yo\node_modules.bin' 2> Check whether SharePoint yeoman generator(@microsoft/generator-sharepoint) installed under '.fx\bin\spGenerator' 3> Add yo executable to env PATH and try to run the following command under an empty folder. Check whether SPFx solution is scaffolded successfully(Replace and to actual value) yo <HOME>\.fx\bin\spGenerator\node_modules\@microsoft\generator-sharepoint\lib\generators\app\index.js --skip-install true --component-type webpart --component-name helloworld --environment spo --skip-feature-deployment true --is-domain-isolated false --framework react --solution-name <your_solution_name>

Hi @Anandks1993, sorry I missed the comment you left in the brackets. Here I mean the .fx folder under HOME directory, not the one in newly created project. Could you help check?

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft This is what I am getting when I tried from an empty folder. I assume error is thrown because of the Username as mine is having a SPACE.

Note: If I provide my alternative username which is ANANDK~1 and run the command it works.

image

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, I suspect your issue might be related to your Username with space. Can you help try logon with user that doesn't have space in the name to see whether the issue still exist? If you have to do this with current username, maybe I can trigger a test build for you to verify.

Anandks1993 commented 1 year ago

Hi @HuihuiWu-Microsoft Yes I need to do this with current username as it is my office device. So if you could test with this scenario it would be very helpful. Thanks in advance.

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft Any update on this?

Different Question: Also I need a information regarding teamsfx.login() functionality. I am currently working on a SSO enabled tab app. Where I need to use Graph API to make API calls so we will first get the users consent and make use of that. But once the user gives consent is there any way to avoid the opening of Login Popup (Which opens and closes as the user already provided the consent.). What we need is a way to check about the user consent. We need to open the login popup only when the user is yet to provide consent.

Thanks in advance.

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, I'm working on the friendly build for you to test since others don't have the same issue. Will update to you once ready. Regarding the SDK issue, @tecton can you help answer the question here?

tecton commented 1 year ago

Hi @Anandks1993, you could use teamsfx.getCredential().getToken() if you just want to get the access token. Once you catch the error that user has not consented, you could call teamsfx.login() to open the login popup.

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft Thank you so much, meanwhile I will also check if I can work with another username without space on it.

@tecton Yeah got it, thank you for the quick help.

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, I raised a PR to fix this issue. I can send you daily build tomorrow so you can try whether it resolves the bug.

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft Thank you, will try the build once you send.

HuihuiWu-Microsoft commented 1 year ago

Hi @Anandks1993, please help try the build to see if you still have the problem.

Anandks1993 commented 1 year ago

@HuihuiWu-Microsoft This build is working perfectly :tada:. App is successfully created with this one. Thank you so much for resolving this issue.

I'll leave it to you to close the issue as you may have to publish the changes.

HuihuiWu-Microsoft commented 1 year ago

Great to heat that! Thanks @Anandks1993 for verifying. The fix will be included in next release.

HuihuiWu-Microsoft commented 1 year ago

The fix has already been shipped, close the issue.