Skip to content

Commit 3f88de6

Browse files
csextongauravtiwari
authored andcommitted
Update node-sass troubleshooting information (#2206)
Probably obvious to people who are familiar with the tools, I wasn't sure how to fix the `node-sass` error as described. Hopefully these changes save some other folks some of the time it took me to dig into the sassy issue. Updates the docs to with two bits of information: 1. Guidelines to move any webpack-related packages from `devDependencies` to `dependencies` 2. The instructions to rebuild `node-sass` if needed Was able to verify this works with Rails 6.0.0
1 parent 5edd89d commit 3f88de6

File tree

1 file changed

+23
-9
lines changed

1 file changed

+23
-9
lines changed

docs/troubleshooting.md

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,36 @@
44

55
1. Read the error message carefully. The error message will tell you the precise key value
66
that is not matching what Webpack expects.
7-
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug`.
7+
2. Put a `debugger` statement in your Webpack configuration and run `bin/webpack --debug`.
88
If you have a node debugger installed, you'll see the Chrome debugger for your webpack
9-
config. For example, install the Chrome extension [NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
9+
config. For example, install the Chrome extension [NiM](https://chrome.google.com/webstore/detail/nodejs-v8-inspector-manag/gnhhdgbaldcilmgcpfddgdbkhjohddkj) and
1010
set the option for the dev tools to open automatically. For more details on debugging,
1111
see the official [Webpack docs on debugging](https://webpack.js.org/contribute/debugging/#devtools)
1212

1313
## ENOENT: no such file or directory - node-sass
1414

15-
* If you get this error `ENOENT: no such file or directory - node-sass` on Heroku
16-
or elsewhere during `assets:precompile` or `bundle exec rails webpacker:compile`
17-
then you would need to rebuild node-sass. It's a bit of a weird error;
18-
basically, it can't find the `node-sass` binary.
19-
An easy solution is to create a postinstall hook - `npm rebuild node-sass` in
20-
`package.json` and that will ensure `node-sass` is rebuilt whenever
21-
you install any new modules.
15+
If you get the error `ENOENT: no such file or directory - node-sass` on deploy with
16+
`assets:precompile` or `bundle exec rails webpacker:compile` you may need to
17+
move Sass to production `dependencies`.
2218

19+
Move any packages that related to Sass (e.g. `node-sass` or `sass-loader`) from
20+
`devDependencies` to `dependencies` in `package.json`. This is because
21+
webpacker is running on a production system with the Rails workflow to build
22+
the assets. Particurly on hosting providers that try to detect and do the right
23+
thing, like Heroku.
24+
25+
However, if you get this on local development, or not during a deploy then you
26+
may need to rebuild `node-sass`. It's a bit of a weird error; basically, it
27+
can't find the `node-sass` binary. An easy solution is to create a postinstall
28+
hook to ensure `node-sass` is rebuilt whenever new modules are installed.
29+
30+
In `package.json`:
31+
32+
```json
33+
"scripts": {
34+
"postinstall": "npm rebuild node-sass"
35+
}
36+
```
2337

2438
## Can't find hello_react.js in manifest.json
2539

0 commit comments

Comments
 (0)