1

I need to create an SPFx web part for SharePoint 2016. I have been following the instructions here but am getting an error when running "yo @microsoft/sharepoint".

I know that versions of packages really matter, so let me describe those:

  • node v8.17.0 (using nvm)
  • @microsoft/generator-sharepoint@1.0.2 (globally installed)
  • gulp@3.9.1 (globally installed)
  • npm@3.10.10 (globally installed)
  • yo@2.0.0 (globally installed)

After having trouble the first time, I tried my best to replicate everything Vesa had in the video at the link further above. Everything is exactly as his versions show except he doesn't mention his version of node. I read that it had to be 8.x for SP2016 web parts, so I chose the latest 8.x version (8.17.0).

Getting npm to use 3.10.10 was actually a little bit of work best described here.

When running "yo @microsoft/sharepoint" I chose "No JavaScript web framework" just to keep things simple (although I want React). The first error I get is the following (there are a few other errors after this one).

Downloading binary from https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":

HTTP error 404 Not Found

Going to that web page they clearly don't keep versions that old. Is there any recommended set of versions for node and npm packages I should use? Are there workarounds I should be using instead to fix this specific issue?

For attempt #2 (I'll call it #2, but I really tried a few before the one above), I went up to 1.1 on SPFx:

  • node v8.17.0 (using nvm)
  • @microsoft/generator-sharepoint@1.1.0 (globally installed)
  • gulp@3.9.1 (globally installed)
  • npm@3.10.10 (globally installed)
  • yo@2.0.0 (globally installed)

I got the same initial error as attempt #1 (I didn't look to see if the errors after that matched).

For attempt #3 I went down to 6.x on node:

  • node v6.17.1 (using nvm)
  • @microsoft/generator-sharepoint@1.1.0 (globally installed)
  • gulp@3.9.1 (globally installed)
  • npm@3.10.10 (globally installed)
  • yo@2.0.0 (globally installed)

This time the error (and only output) for "yo @microsoft/sharepoint" was:

C:\Users\Kirk\AppData\Roaming\nvm\v6.17.1\node_modules\yo\node_modules\yeoman-environment\lib\environment.js:154
      options = {singleResult: !options.multiple, ...options};
                                                  ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Users\Kirk\AppData\Roaming\nvm\v6.17.1\node_modules\yo\lib\router.js:9:54)
1

I think SPFx v 1.0 only supports node.js v 6.x.

This is the compatibility matrix:

  • SPFx 1.0.0
  • Node.js LTS 6.x
  • npm v3
  • TypeScript v2.4
  • React v15.x
  • Yeoman 2 (need to confirm)

Source: SPFx Development Environment Compatibility by HUGO BERNIER

4
  • Thanks! I'll give this a shot and respond with my findings... – Kirk Liemohn Apr 27 at 19:18
  • 1
    I am seeing on docs.microsoft.com/en-us/sharepoint/dev/spfx/… where it has "That's why if you're building SPFx solutions for SharePoint Server 2016, you should use Node.js v8.x." but I will try 6.x (6.17.1 appears to be the latest 6.x). – Kirk Liemohn Apr 27 at 19:47
  • Right. Maybe you can also try SPFx 1.1.0 instead of 1.0.2 – Denis Molodtsov Apr 27 at 20:08
  • 1
    I'm getting an error with Node 6.17.1. I'll update my original post to provide the details. – Kirk Liemohn Apr 27 at 20:12
1

You can take a look at this article: https://www.voitanos.io/blog/spfx-which-version-of-spfx-generator-to-install/

In Node.js v8.x, you'd run the command

NODE_NO_HTTP2=1 gulp serve
1
  • Wow. AC's blog post is directly contradictory to Vesa's video on the official documentation here: docs.microsoft.com/en-us/sharepoint/dev/spfx/…. After some fiddling this did result in a process that lets me build, package, and run in the workbench. I still have no luck running it on SP2016 (w/FP2) yet. I will post an answer showing two scenarios that at least build/package for me. – Kirk Liemohn Apr 29 at 14:17
0

I have two scenarios that solved my immediate problem:

Scenario 1

  • node v6.10.3 (using nvm)
  • @microsoft/generator-sharepoint@1.1.0 (globally installed)
  • npm@3.10.10 (globally installed)
  • yo@1.8.5 (globally installed)

Scenario 2

  • node v8.17.0 (using nvm)
  • @microsoft/generator-sharepoint@1.9.1 (globally installed)
  • npm@3.10.10 (globally installed)
  • windows-build-tools@5.2.2 (globally installed)
  • yo@1.8.5 (globally installed)

I don't know if the Windows build tools were required, but in my various tests they were still there for this one. I tried the latest version of the Yeoman generator and it did not work.

In both cases I didn't need gulp globally installed, but it did require me to add scripts to package.json in order to do my gulp commands. For scenario 2, I had a "serve" script with a value of "set NODE_NO_HTTP2=1 && npm run serve-internal" and a "serve-internal" script that does a "gulp serve". I can't simply run "NODE_NO_HTTP2=1 gulp serve" because a) I have a pathing issue with running npm directly (probably a simple fix I didn't explore) and b) you need to format the command differently for Windows (which I am on).

In both cases I can do a "gulp bundle --ship" and "gulp package-solution --ship" (both through package.json scripts. I can deploy them to SP2016 into the app catalog. I can add each app to a site collection, but trying to see the web part when adding a web part to a page looking in the "Under Development" category only worked for the first and then only after several hours. It almost seemed like deploying scenario 2 triggered scenario 1 to work. The web part still fails in Scenario 1, but I'll leave that for another question since the "immediate problem" is solved based on how I worded the question/problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.