evont-software.com
.jpg?2025-10-24T06:36:47.393Z)
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.
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 π
node-sassnode-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.
SASS_BINARY_SITEHost 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
--sass-binary-dirIf you have the binary file locally:
npm rebuild node-sass --sass-binary-dir="C:\offline\sass-binaries\v4.14.1"
SASS_BINARY_PATHIf 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.
gulp-sassgulp-sass depends on node-sass, so it triggers the same binary download issue.
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
fseventsfsevents is a macOS-specific file watcher dependency that tries to compile native code.
Itβs not needed on Windows or Linux.
Skip optional dependencies:
npm install --no-optional
This avoids downloading or compiling fsevents entirely.
phantomjs-prebuiltAttempts to download the PhantomJS binary from the internet:
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/...
Host the PhantomJS binary internally and set:
set PHANTOMJS_CDNURL=http://nexus.local/repository/phantomjs/
Publish it on a local path and add it to path environment variable
PATH += c:/tools/phantomjs/bin
node-gyp (used by several modules)node-gyp downloads Node.js headers and build tools to compile native modules.
npm config set node_gyp_node_dir "C:\offline\node-headers"This ensures native modules can build without external downloads.
gulp-imagemingulp-imagemin downloads image optimization binaries (mozjpeg, pngquant, etc.) from the internet.
Skip running post-install scripts that trigger downloads:
npm install gulp-imagemin --ignore-scripts
If needed, install binaries manually and configure paths manually.
canvas / node-canvasTries to compile C/C++ libraries and download external build headers.
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.
office-ui-fabric-react and other Microsoft UI packagesSome Microsoft UI packages attempt telemetry, audit, or funding requests when installed.
Disable telemetry and audit features:
npm set fund falsenpm set audit falsenpm set update-notifier false
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 falsenpm set audit falsenpm set fund falsenpm 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
Package | Problem | Offline Fix |
|---|---|---|
node-sass | Binary download from GitHub | Use |
gulp-sass | Depends on | Same fix or use |
fsevents | macOS-only native module |
|
phantomjs-prebuilt | Downloads PhantomJS binary | Set |
node-gyp | Downloads Node headers | Preinstall headers / build tools |
gulp-imagemin | Downloads optimization binaries | Install with |
canvas | Compiles C/C++ binaries | Build from source or host internally |
office-ui-fabric-react | Telemetry / audit requests | Disable audit and funding |
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.