evont-software.com

Email: info@evont-software.com

Installing SPFx Packages for SharePoint 2019 via Nexus (Offline or Limited Internet)

Category:SPFX
Date:
Author: Mathias Osterkamp

Developing SPFx (SharePoint Framework) solutions for SharePoint 2019 in a restricted environment is a common enterprise scenario.
Organizations often use Nexus Repository Manager to cache npm packages locally and block external internet access.

While most SPFx dependencies work fine through Nexus, some packages still try to download binaries or resources from the web during installation.
These cause npm install to fail unless handled explicitly.

This article summarizes the most common problematic packages (like node-sass, gulp-sass, fsevents, etc.) and how to install them successfully in an offline environment.


Typical Setup

  • SharePoint 2019
  • SPFx 1.4.1 or 1.5.1
  • Nexus Repository Manager as npm proxy
  • Node.js 8.x or 10.x
  • No direct internet connection

The Root Problem: Native Modules & Binary Downloads

Some npm packages require precompiled binaries or try to compile native code after downloading headers or assets from the internet.
Nexus only caches npm packages β€” it does not proxy GitHub or binary releases.
So when these packages attempt to download extra files, installation fails.

Let’s go through them one by one πŸ‘‡


1. node-sass

Problem:

node-sass downloads a platform-specific binary from GitHub during post-install:

Downloading binary from https://github.com/sass/node-sass/releases/...

This fails without internet access.

Solution A β€” Use SASS_BINARY_SITE

Host the binary internally (e.g., in Nexus or on a web server) and set:

set SASS_BINARY_SITE=http://nexus.local/repository/node-sass-binaries/
npm rebuild node-sass

Solution B β€” Use --sass-binary-dir

If you have the binary file locally:

npm rebuild node-sass --sass-binary-dir="C:\offline\sass-binaries\v4.14.1"


Solution C β€” Use SASS_BINARY_PATH

If you have the binary file locally use environment variable:

SASS_BINARY_PATH="C:\offline\sass-binaries\v4.14.1\binding.node"

πŸ’‘ Download binaries from https://github.com/sass/node-sass/releases on an online machine and store them in Nexus or offline storage.


2. gulp-sass

Problem:

gulp-sass depends on node-sass, so it triggers the same binary download issue.

Solution:

Follow the same fix as node-sass β€” either set SASS_BINARY_SITE or rebuild with --sass-binary-dir.

If you can, upgrade to gulp-dart-sass, which does not require native binaries:

npm install gulp-dart-sass


3. fsevents

Problem:

fsevents is a macOS-specific file watcher dependency that tries to compile native code.
It’s not needed on Windows or Linux.

Solution:

Skip optional dependencies:

npm install --no-optional

This avoids downloading or compiling fsevents entirely.


4. phantomjs-prebuilt

Problem:

Attempts to download the PhantomJS binary from the internet:

Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/...

Solution A:

Host the PhantomJS binary internally and set:

set PHANTOMJS_CDNURL=http://nexus.local/repository/phantomjs/

Solution B:

Publish it on a local path and add it to path environment variable

PATH += c:/tools/phantomjs/bin



5. node-gyp (used by several modules)

Problem:

node-gyp downloads Node.js headers and build tools to compile native modules.

Solution:

  • Preinstall Python and Windows Build Tools offline:
    npm install --global --production windows-build-tools
  • Cache Node.js headers locally:
    npm config set node_gyp_node_dir "C:\offline\node-headers"

This ensures native modules can build without external downloads.


6. gulp-imagemin

Problem:

gulp-imagemin downloads image optimization binaries (mozjpeg, pngquant, etc.) from the internet.

Solution:

Skip running post-install scripts that trigger downloads:

npm install gulp-imagemin --ignore-scripts

If needed, install binaries manually and configure paths manually.


7. canvas / node-canvas

Problem:

Tries to compile C/C++ libraries and download external build headers.

Solution:

Install system dependencies manually first:

npm install --build-from-source

or use prebuilt binaries hosted internally.

If node-canvas is not essential, consider removing it from your project to simplify offline setup.


8. office-ui-fabric-react and other Microsoft UI packages

Problem:

Some Microsoft UI packages attempt telemetry, audit, or funding requests when installed.

Solution:

Disable telemetry and audit features:

npm set fund false
npm set audit false
npm set update-notifier false


General npm Configuration for Offline SPFx Installs

Before installation, configure npm to use Nexus and disable unnecessary online checks:

npm set registry http://nexus.local/repository/npm-all/
npm set strict-ssl false
npm set audit false
npm set fund false
npm set update-notifier false

And install using:

npm install --offline --no-optional --ignore-scripts

After installation, manually rebuild native modules like node-sass:

npm rebuild node-sass


Summary

Package

Problem

Offline Fix

node-sass

Binary download from GitHub

Use SASS_BINARY_SITE or --sass-binary-dir

gulp-sass

Depends on node-sass

Same fix or use gulp-dart-sass

fsevents

macOS-only native module

npm install --no-optional

phantomjs-prebuilt

Downloads PhantomJS binary

Set PHANTOMJS_CDNURL

node-gyp

Downloads Node headers

Preinstall headers / build tools

gulp-imagemin

Downloads optimization binaries

Install with --ignore-scripts

canvas

Compiles C/C++ binaries

Build from source or host internally

office-ui-fabric-react

Telemetry / audit requests

Disable audit and funding


Final Thoughts

Even in fully restricted environments, you can successfully build and package SPFx solutions for SharePoint 2019 with the right setup.
By combining Nexus for npm proxying and a few environment tweaks for native modules, your builds become reliable, repeatable, and fully offline.