Skip to content

Local gulp not found #3575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 4 tasks
fernandoagomezf opened this issue Mar 11, 2019 · 10 comments
Closed
1 of 4 tasks

Local gulp not found #3575

fernandoagomezf opened this issue Mar 11, 2019 · 10 comments
Labels
area:tooling Category: Development tooling status:answered Answer to a question.

Comments

@fernandoagomezf
Copy link

fernandoagomezf commented Mar 11, 2019

Category

  • Question
  • Typo
  • Bug
  • Additional article idea

I'm following the instructions of the article[1], however executing the command "gulp trust-dev-cert" or "gulp serve" I get the following error:

C:\Users\ferna\source\helloworld-webpart>gulp trust-dev-cert
[15:44:57] Local gulp not found in ~\source\helloworld-webpart
[15:44:57] Try running: npm install gulp

I already installed gulp through the previous "npm install -g gulp" command, but I run the command again (this time without the -g as specified by the suggestion, and I get the same error. Any suggestion as to why is this happening? I made sure "C:\Users\ferna\AppData\Roaming\npm" is on PATH, but still get the same result...

[1] Articles:
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part
https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment

On a related note, will there be ever a version of SPFx for Visual Studio that just works with one click, as with previous versions of SharePoint?

@msft-github-bot
Copy link
Collaborator

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

@msft-github-bot msft-github-bot added the Needs: Triage 🔍 Awaiting categorization and initial review. label Mar 11, 2019
@fernandoagomezf
Copy link
Author

Following advise I found in Stack Overflow, I executed "npm link gulp". Now when executing gulp serve or gulp trust-dev-cert I get the following error:

C:\Users\ferna\source\helloworld>gulp trust-dev-cert
module.js:550
throw err;
^

Error: Cannot find module '@microsoft/sp-build-web'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (C:\Users\ferna\source\helloworld\gulpfile.js:4:15)
at Module._compile (module.js:653:30)
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)

@fernandoagomezf
Copy link
Author

I finally managed, it took me long enough. These are the steps I did to solve the problem, should anyone find him/herself in the same position.

  • Uninstalled Visual Studio's Node.js and installed a fresh one, v8.
  • Installed gulp, yo and @microsoft/generator-sharepoint as depicted in Microsoft's SPFx documentation site[1].
  • Navigate (using command line, ugh) to the folder where you'll be creating your webpart and run "yo @microsoft/sharepoint" command. The article is lacking a question, mainly if you want to build webparts or extensions, so I chose webpart.
  • Attempt to run "gulp trust-dev-cert" or "gulp serve" will yield error "Local gulp not found in ~\yourfolder". To solve it, I ran the following command: "npm link gulp" [2].
  • Next attempt to run "gulp trust-dev-cert" or "gulp serve" yield error "Cannot find module '@microsoft/sp-build-web". To solve it, I ran the following command: "npm install --save-dev". [3]
  • Next attempt to run "gulp trust-dev-cert" or "gulp serve", I got the error "gulp serve cannot find module semver". To solve it, I ran the command "npm install gulp-cli -g" [4]. After ten minutes of doing nothing visible, I aborted with Ctrl+C and ran again the command. This time it worked.
  • After all these stuff, I finally managed to run both commands and got my hello world webpart running in the benchmark.

From what I could gather, the problems are related to invalid cache (i.e. the way npm/yo are supposed to get packages from online repository) and problems with the way these tools are installed in Windows (they were written originally for Linux), hence the need of manually going through those additional commands. I really hope one day SPFx will be available for Visual Studio instead of relying on (bugged?) third party tools. After all, we pay lots of dollars for our VS subscription!

Hope this helps someone to troubleshoot their installation.

[1] https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part
[2] https://stackoverflow.com/questions/38103889/local-gulp-not-found-try-running-npm-install-gulp
[3] #15
[4] http://sharepointerthilosh.blogspot.com/2017/12/sharepoint-frameworkspfx-gulp-error.html

@andrewconnell
Copy link
Collaborator

The typical reason for this is because you didn't run npm install after creating a new project with the Yeoman SPFx generator. This happens automatically after the generator completes... so verify that happened.

To be clear:

To solve it, I ran the following command: "npm link gulp" [2].

That is not required or expected you have to do that.

Gulp is special in that you need it installed globally & locally. The steps only have you install it globally because the default scaffolding generated by SPFx's Yeoman generator sets it up for local install.

@andrewconnell andrewconnell added area:tooling Category: Development tooling status:answered Answer to a question. and removed Needs: Triage 🔍 Awaiting categorization and initial review. labels Mar 12, 2019
@fernandoagomezf
Copy link
Author

Hi Andrew, thank you for your comment.

I did follow the step-by-step procedure depicted in the documentation. I did ran "npm install -g yo gulp" and "npm install -g @microsoft/generator-sharepoint". Then the doc says to run "gulp trust-dev-cert". There's a note below that reads "This assumes you have installed all dependencies with npm install after creating the project. This step will install all gulp tasks as part of a project." If this refers to what you say, then I would suggest to add something more descriptive. Specifically, if the doc is going on a step by step basis, it would be better if a previous step to "gulp trust-dev-cert" was "npm install" with the explanation you gave me, and before, not after. It might save trouble for a lot of people who, like me, are having to learn three of four new tools to do stuff that previously only needed a "press F5 to run" in Visual Studio.

Thanks again!

@andrewconnell
Copy link
Collaborator

Not sure you understood what I was saying.

When you follow the setup instructions here: https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-development-environment

... you get to the part where it talks about Trust the self-signed developer certificate. It states:

A utility task is included in every SharePoint Framework project in the form of a gulp task. You can elect to do this now, or wait until you create your first project as covered in the Build your first SharePoint client-side web part (Hello World part 1): Preview the web part tutorial.

... Once a project has been created with the Yeoman generator for the SharePoint Framework

The part I italicized is the important piece. In that tutorial, the one you linked to, after step 5 the steps say

At this point, Yeoman installs the required dependencies and scaffolds the solution files

That's the key... once you have created the project & the dependencies have been installed, only then can you run gulp trust-dev-cert from within the project.

The steps are pretty clear... you install install some tools (gulp, yeoman and the SPFx yeoman geneartor) globally. The next step is to trust the dev cert, but that must be done from a project so you create a project and once it's been provisioned and all dependencies have been created, you can trust the dev cert.

@fernandoagomezf
Copy link
Author

Hello Andrew, thanks for your input.

However, I'm not sure you understand the problem I had. I did follow the instructions to the letter, and not once, but many times. I reached the part "At this point, Yeoman installs the required dependencies and scaffolds the solution files along with the HelloWorld web part. This might take a few minutes." of the tutorial. After the few minutes and Yeoman did whatever it is it does, I tried to run the "gulp trust-dev-cert" and it failed. Again and again. It wasn't until I ran "npm link gulp" that the error was removed (and replaced by other set of errors, as I documented here). You say that step is not needed, and I believe you. But only then it worked for me, despite running the instructions as they are written. Perhaps it is a bug? Or something lacking in my environment? Honestly, I cannot tell, I don't know these tools to venture an opinion.

@andrewconnell
Copy link
Collaborator

Nope... fully understand the problem. What you did should NOT be required. After the dependencies are installed, if you are in the same root folder in the project, you should now have a node_modules folder and within it is where the local gulp was installed.

@govinddk4444
Copy link

Clearing the npm cache and running npm install worked for me

npm cache clean --force

then run

npm install

@msft-github-bot
Copy link
Collaborator

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

@SharePoint SharePoint locked as resolved and limited conversation to collaborators Jan 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area:tooling Category: Development tooling status:answered Answer to a question.
Projects
None yet
Development

No branches or pull requests

4 participants