-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update node-sass troubleshooting information #2206
Conversation
I would not advise using the node buildpack first on Heroku because yarn will end up running multiple times. On our production setup with a large app, it doubled the build time. You can track the issue here: heroku/heroku-buildpack-ruby#654 |
@bbugh I did not realize that. Bummer. I noticed that @schneems recommends manually disabling the Frustrating thing is that the post install script was a hack to rebuild Anyone have suggestions as for a better way to either:
If it is the latter it may be best to open an issue on the ruby build pack repo. What ever it is worth, at least this approach did work -- even if it re-installs node modules a few times in the process 😕 |
The easiest thing to do is to ditch node-sass.
Voila, no more annoying Supposedly the dart version is a little slower than node-sass, but we have a giant project with a ton of CSS and the change was insignificant. |
@csexton Can you share what versions you are using? ( You also may be using a version of node that node-sass does not yet support on all platforms (node 12 was just added). I recommend installing node 10 via nVm. As a last-ditch effort, you can try deleting your yarn.lock file and running @bbugh The method you describe will not override the
Subsequent yarn installs should generally take under a second. Are you referring to the webpack build? |
You're right, but only because I forgot to mention that you need to use yarn's "resolutions": {
"sass-loader": "^7.2.0"
},
That's only true if yarn is defaulted to |
@jakeNiemiec looks like my local machine is running Node 12, but that has been working. Heroku (with both Node and Ruby build packs) has 10.
Seems like installing nVm on the server wouldn't be the best approach, but I could setup a custom build pack pinned to a node version if the official one won't work (I'd just prefer not to if I can help it 😅). |
nVm only required for local. I clarify because homebrew has problems. @csexton I recommend using node 10 until 12 is out of prerelease. There have been a lot of weird errors with 12
You probably also addressed the fact that
Even so, there may be a larger problem if the rake task takes more than a couple of seconds.
Check out the releases since then, webpacker was compiling too much. It has since been fixed. @csexton A problem I can see is going from a node12 env to node10, but I don't have any heroku experience. Can you tell me if downgrading local to node10, deleting your yarn.lock file, and running |
Did some more testing between the different approaches. Method 1: Dart-based SassI was able to get @bbugh's approach to work. Removed "devDependencies": {
- "node-sass": "^4.12.0",
+ "sass": "^1.22.9",
"sass-loader": "^7.1.0"
} Full package.json
Then was able to deploy to Heroku with only the Ruby build pack. 🎉 Method 2: Node 10I tried to follow @jakeNiemiec's suggestion of downgrading Node on my development machine to v10, deleting the Full package.json
But got a very sad
Full Error Message
This was on Heroku with only the Ruby build pack. I still don't fully grok the Webpack, Yarn, and NPM process; so could be doing something silly. If anything jumps out, or I can try something else, please let me know. |
As I stated above Dart-based Sass only worked because If you want to experiment with this yourself, |
Thats interesting. So if a package is included in Based on your advice I tried a couple things: 1) Moving sass packages to productionI moved the two Sass packages to "dependencies": {
"@rails/actioncable": "^6.0.0-rc2",
"@rails/activestorage": "^6.0.0-rc2",
"@rails/ujs": "^6.0.0-alpha",
"@rails/webpacker": "^4.0.2",
"add": "^2.0.6",
"bootstrap": "^4.3.1",
"jquery": "^3.4.1",
"js-storage": "^1.0.4",
"popper": "^1.0.1",
"popper.js": "^1.15.0",
"turbolinks": "^5.2.0",
"yarn": "^1.16.0",
+ "node-sass": "^4.12.0",
+ "sass-loader": "^7.1.0"
},
"devDependencies": {
- "node-sass": "^4.12.0",
- "sass-loader": "^7.1.0",
"webpack-dev-server": "^3.3.1"
}, Yay, it worked! 🎉 2) Removing sass packages entirelyAnd based on the comment about Dart Sass, I just tried deleting both references entirely: "dependencies": {
"@rails/actioncable": "^6.0.0-rc2",
"@rails/activestorage": "^6.0.0-rc2",
"@rails/ujs": "^6.0.0-alpha",
"@rails/webpacker": "^4.0.2",
"add": "^2.0.6",
"bootstrap": "^4.3.1",
"jquery": "^3.4.1",
"js-storage": "^1.0.4",
"popper": "^1.0.1",
"popper.js": "^1.15.0",
"turbolinks": "^5.2.0",
"yarn": "^1.16.0"
},
"devDependencies": {
- "node-sass": "^4.12.0",
- "sass-loader": "^7.1.0",
"webpack-dev-server": "^3.3.1"
}, Also worked! 🎉 Now, the point of the PR in the first place. I'd like to update the docs with a good suggestion for how to get webpacker working on Heroku with a fresh Rails app. Would it be best to have them move the packages to the production |
It's ok. Most node.js folks have this burned into their brains from the 2016 npm@5 disaster. There are many obscure edge cases that don't translate well for rails users. See this for the webpacker history with this issue: #1880 If you have time, in #1212 (comment) & #1212 (comment) I discuss the technical reasons why you really shouldn't use devDeps at all with webpacker. tl;dr: devDeps are for node.js libraries that other apps will install. It is solely a liability for webpacker. I tried to document that here:
I'd say move everything to
You should avoid doing this in order to
|
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
0608407
to
51f478a
Compare
I edited the documentation with the lessons learned here. I have verified this is working with the Rails 6 release on Heroku. With out the need to additional build packs 🎉 |
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:
package.json
Was able to verify this works with Rails 6.0.0.rc2 🎉