Skip to content

Commit 1e47657

Browse files
authored
fix(@angular/cli): don't fail install due to node-sass (#5282)
This change should reduce the amount of problems on npm installs. It makes the `node-sass` dependency optional, and so install will not fail when it cannot be installed. For projects that do not use sass, there is no side-effect of an failed node-sass install. For projects that do use node-sass and the install failed, they should see the following self-explanatory error message: ``` ERROR in ./src/app/app.component.scss Module build failed: Error: Missing binding D:\sandbox\master-project\node_modules\node-sass\vendor\win32-x64-51\binding.node Node Sass could not find a binding for your current environment: Windows 64-bit with Node.js 7.x Found bindings for the following environments: This usually happens because your environment has changed since running `npm install`. Run `npm rebuild node-sass` to build the binding for your current environment. at module.exports (D:\sandbox\master-project\node_modules\node-sass\lib\binding.js:15:13) at Object.<anonymous> (D:\sandbox\master-project\node_modules\node-sass\lib\index.js:14:35) ``` Fix #4429
1 parent d6504e2 commit 1e47657

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@
7777
"magic-string": "^0.19.0",
7878
"minimatch": "^3.0.3",
7979
"node-modules-path": "^1.0.0",
80-
"node-sass": "^4.3.0",
8180
"nopt": "^4.0.1",
8281
"opn": "4.0.2",
8382
"portfinder": "~1.0.12",
@@ -151,5 +150,8 @@
151150
"tree-kill": "^1.0.0",
152151
"ts-node": "^2.0.0",
153152
"tslint": "^4.0.2"
153+
},
154+
"optionalDependencies": {
155+
"node-sass": "^4.3.0"
154156
}
155157
}

packages/@angular/cli/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@
6161
"lodash": "^4.11.1",
6262
"minimatch": "^3.0.3",
6363
"node-modules-path": "^1.0.0",
64-
"node-sass": "^4.3.0",
6564
"nopt": "^4.0.1",
6665
"opn": "4.0.2",
6766
"portfinder": "~1.0.12",
@@ -90,6 +89,9 @@
9089
"webpack-merge": "^2.4.0",
9190
"zone.js": "^0.7.2"
9291
},
92+
"optionalDependencies": {
93+
"node-sass": "^4.3.0"
94+
},
9395
"ember-addon": {
9496
"paths": [
9597
"./"

scripts/publish/validate_dependencies.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ for (const packageName of Object.keys(packages)) {
121121
const packageJson = JSON.parse(fs.readFileSync(packages[packageName].packageJson, 'utf8'));
122122
const allDeps = []
123123
.concat(Object.keys(packageJson['dependencies'] || {}))
124+
.concat(Object.keys(packageJson['optionalDependencies'] || {}))
124125
.concat(Object.keys(packageJson['devDependencies'] || {}))
125126
.concat(Object.keys(packageJson['peerDependencies'] || {}));
126127

@@ -142,6 +143,7 @@ const rootPackageJson = JSON.parse(fs.readFileSync(rootPackagePath, 'utf8'));
142143
// devDependencies are ignored
143144
const allRootDeps = []
144145
.concat(Object.keys(rootPackageJson['dependencies'] || {}))
146+
.concat(Object.keys(rootPackageJson['optionalDependencies'] || {}))
145147
.concat(Object.keys(rootPackageJson['peerDependencies'] || {}));
146148

147149
const internalPackages = Object.keys(packages);

0 commit comments

Comments
 (0)