1

I'm using node 14 and Jenkins behind a corporate proxy I can't get node-sass to install properly.

So I've installed it locally in two places

  • For SASS_BINARY_PATH: /var/jenkins_home/linux-x64-83_binding.node
  • For SASS_BINARY_DIR: /var/jenkins_home/vendor/linux-x64-83/binding.node

I tried SASS_BINARY_PATH:

SASS_BINARY_PATH=/var/jenkins_home/linux-x64-83_binding.node npm install node-sass
npm install --no-lockfile
npm run build

But I get this error when building:

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js): ModuleBuildError: Module build failed (from ./node_modules/sass-loader/dist/cjs.js): Error: ENOENT: no such file or directory, scandir '/var/jenkins_home/workspace/root_project_dir/project/node_modules/node-sass/vendor'

And I tried SASS_BINARY_DIR:

SASS_BINARY_DIR=/var/jenkins_home/vendor npm install node-sass
npm install --no-lockfile
npm run build

But this ends up trying to download the binary which is the problem I'm trying to avoid in the first place.

Any help would be greatly appreciated!

Here's my package.json if that helps:

{
  "name": "name",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "@types/lodash": "4.14.115",
    "axios": "^0.18.0",
    "@types/chart.js": "^2.7.48",
    "chart.js": "^2.7.2",
    "chartjs-plugin-datalabels": "0.7.0",
    "http2": "^3.3.7",
    "lodash": "4.17.10",
    "typescript": "^3.2.0",
    "vue": "^2.5.16",
    "vue-async-computed": "^3.3.1",
    "vue-chartjs": "^3.4.0",
    "vue-class-component": "^6.0.0",
    "vue-property-decorator": "^7.0.0",
    "vue-router": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-rc.12",
    "@vue/cli-plugin-typescript": "^3.0.0-beta.15",
    "@vue/cli-service": "^3.0.0-beta.15",
    "node-sass": "^4.9.0",
    "sass-loader": "^7.0.1",
    "vue-template-compiler": "^2.5.16"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

2 Answers 2

1

I solved this by manually creating the node_modules/node-sass/vendor directory after npm install and copying the binding.node into the linux-x64-83 directory:

npm install node-sass --sass-binary-path="/var/jenkins_home/linux-x64-83_binding.node"
npm install --no-lockfile
mkdir -p node_modules/node-sass/vendor/linux-x64-83
cp /var/jenkins_home/linux-x64-83_binding.node node_modules/node-sass/vendor/linux-x64-83/binding.node
npm run build
Sign up to request clarification or add additional context in comments.

1 Comment

This is exactly the solution I needed. :hat-tip:
1

Say you have an empty directory C:\res\node-sass, which will be used as SASS_BINARY_DIR. The following steps show how I specify SASS_BINARY_DIR correctly:

So the downloaded win32-x64-83_binding.node actually becomes %SASS_BINARY_DIR%\win32-x64-83\binding.node

In addition to specifying SASS_BINARY_DIR in file .npmrc, you can also export it as environment variable with set SASS_BINARY_DIR=C:\res\node-sass on windows.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.