10

I am working on the SharePoint Framework Tutorial 1 for the Hello World Web Part. When running the build command gulp serve to build and preview the webpart I get the following error "Cannot find module '@microsoft/sp-build-web'".

Here are the details:

PS C:\src\spfm\helloworld-webpart> gulp serve module.js:327 throw err; ^ Error: Cannot find module '@microsoft/sp-build-web' at Function.Module._resolveFilename (module.js:325:15) at Function.Module._load (module.js:276:25) at Module.require (module.js:353:17) at require (internal/module.js:12:17) at Object.<anonymous> (C:\src\spfm\helloworld-webpart\gulpfile.js:4:15) at Module._compile (module.js:409:26) at Object.Module._extensions..js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Module.require (module.js:353:17)

I've checked the project structure and under the node_modules/@microsoft path I can see the following folders but not sp-build-web

  • sp-client-base
  • sp-client-preview
  • sp=modules-interface
  • sp-webpart-workbench

Any ideas?

Asad Refai
  • 5,971
  • 8
  • 34
  • 57
Dimitrie Agafitei
  • 101
  • 1
  • 1
  • 5

4 Answers4

6

Update to node package manager (npm) 3 using npm -g install npm@next and your path length issues should go away

This is because the LTS version of node ships with npm v2.x whereas npm 3.x has better package handling and doesn't create such deeply nested folders.

DvG
  • 2,332
  • 2
  • 13
  • 31
GavinB
  • 2,013
  • 12
  • 16
4

I had the same issue when I couldn't install Phantom due to an error on their server. I fixed the issue by rerunning npm i in the command line.

Waldek Mastykarz
  • 2,514
  • 12
  • 8
4

Late to the party, but the only thing that worked for was:

npm install @microsoft/sp-build-web@1.6.0

But I still get other errors and gulp serve still won't run so I give up - customizing classic was so much quicker and easier...

matt
  • 589
  • 3
  • 23
0

My corporate environment doesn't use a proxy as I couldn't be able to locate in internet explorer settings. But there are firewalls which blocks everything. I used following command and '@microsoft/sp-build-web' error was resolved.

Command: npm install --save-dev '@microsoft/sp-build-web'

I followed the web and got many resolutions but putting the above worked. Hope this helps somebody.

Thanks