Compiling node-sass takes 10 minutes - node.js

We operate many small websites. We usually host them on Digital Ocean's $5-$10 servers.
Part of our deployment is compiling of Sass to CSS using node-sass.
On our latest server we experience a significant increase in compiling time for node-sass library (not the actual scss files). We're talking about 8-10 minutes, where in other projects it takes 30sec - 100sec.
We use node 8.11.1 (newest LTS) and yarn 1.6.0 (newest) with node-sass 4.8.3 (newest) on Ubuntu 16.04.4.
Is there any way to cache the compilation between deployments? Or is anyone aware why its taking so much time to compile node-sass?

If someone finds this through search engine:
We did not find any solution for the issue.
We scaled the droplet up and down back to it's original size and the problem was gone.

If you're running a supported OS and Node combination (see the release page on GH for your version of node-sass), the pre-built binary should be downloaded for you.

npm install
yarn has some issues with caching (could be on your PC, or on CDN). That could lead to huge time increase if you have a few node version on your PC (e.g. nvm). In my case installing dependencies with npm worked: 40 seconds, compared to 5+ minutes with yarn (I didn't wait till the end)

I ran into this after working on a site first on my Mac Mini then on my PC. I had this:
const sassCompiler = require('gulp-sass')(require('sass'));
On the Mac it worked decently, perhaps the M1, but on my PC which is a few years old but high-end, it took around a minute for every CSS change.
I checked the docs and the second parameter (require('sass')) indicates the compiler and that the main two options are sass and node-sass.
Since I am using Yarn I did yarn add node-sass to my project. Then modified my gulpfile line to this:
const sassCompiler = require('gulp-sass')(require('node-sass'));
The difference is tenfold.
With SASS compiler:
With Node-SASS compiler:
I still haven't tried the new config on my Mac, but I don't think there would be a big difference.

Related

Node Version Manager runs very slow on M1 Macbook Air

I am currently finding that running Node Version Manager on my M1 Macbook (using zsh console), it is running node commands very slowly.
An npm install can take 30+ minutes to complete.
However, if I don't use NVM and decide to install the same version of node directly, the commands runs much faster as expected (2 minutes for an npm install).
I have tried using different versions of node with NVM and the commands still run slow.
I have also tried to run terminal using Rosetta and they still take forever to run.
Looking around I have seen people complain about NVM starting slowly but mine loads almost instantly, its just commands running that takes a long time.
Is this just an M1 chip issue or have I possibly done something wrong?
I had the same problem, installing the node version using the 64-bit X86 architecture fixed the issue.
Here is the instruction(look at section: Macs with M1 chip):
https://github.com/nvm-sh/nvm#macos-troubleshooting
Eventually, I found that changing the version of node helped immensely.
I was using node 12 at the time of the question and since upgrading to node 15 using NVM, I found that it ran much quicker and was actually usable.

Angular compiler is slow between two identical model laptops

Coworker and I are trying to figure out why compilation times are different. We have the same exact Dell Laptop 7030 model, same SSD, same hard drive, same memory, specs. Our task manager process look similar.
Corporate orders the identical model computers.
We are downloading from Angular Git Repository, with config and package json, with same node size memory.
Question is, Initial build between our laptops is 2 min compared to 8 min.
When we edit a single word in same file, his only takes 5 seconds to recompile, my takes 20 seconds.
Only programs running on the identical computer is Angular command ng serve.
Does anyone have ideas to resolve this issue, and slow compile time?
Is there anything I can change in my work station to the compile speed similar?
Attemped the solutions for all coworkers, still slow
We have same Node.js versions
updated from Angular 8 to 10 in Company Project Git Repo
tried npm cache clear
attempted Uninstalling and Reinstalling Angular and Nodejs
ScanDisk from Windows does not show errors on SSD drive
compared package-lock.json with coworker, they are the exact same, compared in source control diff
turned on Windows Defender Exclusion on the Angular Git Folder
Resources:
Angular compilation slow
How to speed up the Angular build process
Update:
Just noticed my laptop really stalls on styles.scss file at 48%
As you described enough, All the things are the same, whether node or angular versions, Hardware models, software and configurations. You also ensured that build pipelines are the same.
The only thing which comes to mind is a few difference in dependencies, yes the version mismatch inside node_modules packages. Considering that when you dont specify exact versions like ^x.x.x (aka semantic versioning) includes everything greater than the particular version in the same major range for dependency to be installed by npm or yarn. There's a tool named npm semver to show this. In this way, You have to check the installed packages versions too, by opening each one and looking inside package.json file. Specially for those which you think affect the performance like sass loader. Performance for each release may be different.
If you are running exactly the same codebase.
I would with a high degree of confidence say that it is
node.js or different npm versions that is the problem
try running
node --version
npm --version
yarn --version
to see which versions of them you have installed.
for angular 9 I would suggest running node 12, which is the current LTS (Long Time Support) version.
until node 14 which is also out now, but it's LTS release is not until october 2020.
I find yarn to be magnitudes faster than npm, so if you want a speed boost try running that if you haven't tried it.
Also Try clearing the npm cache, as mentioned per comments.
npm cache clear

Installing node takes up to 8 minutes

I am on the latest High Sierra build.
When I am installing an npm (node), it takes up to 8 minutes to install...
🍺 /usr/local/Cellar/node/8.5.0: 4,152 files, 47.8MB, built in 7 minutes 51 seconds
Is this normal behaviour?
It is not normal. I should take longer if you're building from the sources and shorter if you're installing the binary packages. See the install options at:
https://nodejs.org/en/download/
Also you can see this tutorial on installing Node using any type of those packages (binary and source) with exact commands that you need to run:
https://gist.github.com/rsp/edf756a05b10f25ee305cc98a161876a
I never recommend installing a programming language runtime (Node, Python, Ruby, Perl etc.) with anything other than official packages because it can cause all sorts of problems. Those runtimes have their own package manager s that you should use to install modules and libraries and using something else for that can cause hard to track problems and is usually not worth the hassle. The only tool that I can recommend here is nvm because I've read its source code and I know what it's doing, though I would never run the recommended way of piping the curl output straight to bash without seeing what I downloaded first.

What versions of Angular 2 and Angular-cli worktogether on windows vista?

would anybody happen to know the latest versions that work together on Windows Vista? I've been back and forth trying to get the right combination together but ng new never works for some reason or another.
(this is the older post showing what I already tried)
I'm having a bit of a problem here. I attempted to update angular/cli and I got errors telling me I need to update my version of node. I have windows vista so I'm pretty much stuck with node 5.7 and npm 3.6 until I can afford a new computer.
I tried uninstalling angular and clearing the cache and installing angular-cli#1.0.0-beta.14 and it installs. I can create a new project with it though it takes a long time to create it, and it also throws an error with node-pre-gyp. I came across an article on Github that said it's meant to be installed locally in the project and not globally. So I tried uninstalling, clearing cache and installing without -g to make it local within my project folder and it still has errors installing and I still can't serve my project.
How can I clear this all up and just start back with a clean slate of Angular2? I've looked around and everything I find leads me to the docs which are now updated to something beyond what my computer can handle.
I have windows vista so I'm pretty much stuck with node 5.7 and npm 3.6 until I can afford a new computer.
Have you considered running Linux? There are many versions with a lightweight GUI that runs well on older hardware. Ubuntu Mate is an example. It's harder to run node on Windows because of symlinks.

Building react native project on xcode takes for ever (very slow) on the process Running 1 of 1 custom shell script

It seems a strange behavior. I have zsh and for development I use nvm
But I also seem to have node installed by brew.
The packager runs but the xcode appears to wait till the packager is ready but It is already!
So I take more than 20 minutes !!
When it used to be very fast.
Not sure if it is watchman, node version, bash. Or something else. But it is driving my crazy,
Hope you could help me find a solution.
Versions:
react-native-cli: 2.0.1
node --version
v6.11.2
What version of node is recommended to work with React Native?
Have you tried clearing your caches within Xcode?
How to Empty Caches and Clean All Targets Xcode 4
Other than that have you ensured your PATH is setup properly with the version of react-native you're trying to execute?

Resources