Question

Reading the SPFx documentation I find it difficult to understand which service/tool/framework handles requests as a web server. From documentation both Node and Gulp can be used as a web server during development.

Abstracting tools

Node is a runtime which makes me think it's close to CLR on Windows machines. Gulp on the other hand is a task runner which makes me think it's an IIS website or its application pool. If I start gulp serve I can access my webpart in localhost. If I stop it, I can't.

Does Node or Gulp act as webserver during webpart development?

Était-ce utile?

La solution

Neither Gulp or Node act as the web server. The web server used for SPFx is Connect, see below.

These are (some of) the different moving parts in the SPFx workbench

  • Node.js: is the JavaScript runtime, using Chrome V8 JavaScript engine (could be compared to .NET CLR)
  • Gulp: is a build system for Node.js (also known as a task runner)
  • Gulp-connect: is a Gulp task using the Connect web server
  • Connect: is a http server for Node.js

Autres conseils

SPFx uses a Gulp plugin called Gulp connect to start the webserver hosting the Workbench.

You're right saying that Gulp is a task-runner. In a way you could compare it MSBuild in .NET development. Also your comparison of Node to CLR is correct in the context of SPFx.

Node is the underlying server module for #spfx, so install node first and make sure its path is included in the system path.

I then created a windows command file (CMD) with the following contents an called it: installs.cmd


    call npm uninstall -g chalk
    call npm uninstall -g loadash
    call npm uninstall -g tar-fs
    call npm uninstall -g update-notifier
    call npm uninstall -g yeoman-generator
    call npm uninstall -g yosay
    call npm uninstall -g yo
    call npm uninstall -g gulp
    call npm uninstall -g @microsoft/generator-sharepoint

    call npm install -g chalk
    call npm install -g loadash
    call npm install -g tar-fs
    call npm install -g update-notifier
    call npm install -g yeoman-generator
    call npm install -g yosay
    call npm install -g yo
    call npm install -g gulp

    call npm install -g @microsoft/generator-sharepoint

after this cmd runs, the you can type: yo @microsoft/generator-sharepoint to create your webpart....

Cheers,

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top