Reputation: 2100
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
/var/jenkins_home/linux-x64-83_binding.node
/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"
]
}
Upvotes: 1
Views: 4790
Reputation: 3352
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:
npm install
under your project rootwin32-x64-83_binding.node
win32-x64-83
under C:\res\node-sass, notice that win32-x64-83
comes from part of the filename win32-x64-83_binding.node
binding.node
SASS_BINARY_DIR=C:\res\node-sass
to .npmrc under the application rootnpm i
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.
Upvotes: 1
Reputation: 2100
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
Upvotes: 1