Fabric.js on Node 4+ - node.js

It seems to be a known issue that Fabric.js will fails to install out of the box on node.js >=4.
Is it possible to make it work on node >=4? And if not, is there a way to still use it on a node >=4 app, or does the fact that fabric itself only works on node <4 forces me to write my whole app in <4 as well?
Is it possible to two separate versions of node simultaneously, using v0.12 just to run the fabric module, and v4+ for the app itself? Is this approach even worth investigating?

Related

Node 12 | Reference error: FinalizationRegistry is not defined

I am trying to host a node js (express) at dream host using shared unlimited plan. I was able to do most of the work. There is only one problem, dreamhost uses passenger to run node js app, and passenger does not support node 14+, so I have to stick with node v12.
The express js project I was building is built on typescript and I used node v16 to do all of the stuff installing, running etc. When I build the typescript, it uses an npm package exit-free-leak which uses FinalizationRegistry, hence requires node v14+.
So after building the app, When I run the app.js with node v12 it gives me the error that FinalizationRegistry is not defined. For now I am getting this error, but the exit-free-leak uses another node v14+ function "WeakRef".
So my question is how do I get around this issue while using node v12 ? is there anyway to polyfill these functions or disable use of the package exit-free-leak using tsconfig.json, or maybe an even better solution.
Unfortunately the answer to "how do I get around this issue while using node v12" is probably: "you don't".
Node 12 has been end-of-life for 9 months; given how fast the JavaScript ecosystem moves in general, it's unlikely that libraries will keep supporting that version for very long anyway.
You'd be best off asking Dreamhost about Node 16 or 18 support, or move elsewhere if they can't provide you with up-to-date runtimes that still get security updates.

Could i use differents node versions between my project and specific library?

i will try to give you a little of context.
With my team we are trying to migrate MUI v3 to v4 in a reactJs project. We did it with the project itself and it works! but, some kind of problems came up when we navigated to certain windows that use a certain library to work.
This library was developed by other guy that is not in the company anymore and we are not in touch neither, but, we have access to the library GitHub repository, them are two actually.
https://github.com/rjpizarro/forms
https://github.com/rjpizarro/make-request
i've never had to do this so, i decided to clone the project then install the dependencies and run it.
I'm using nvm so in that moment i was working with node v12 and i got some errors when i executed the npm start ("start": "webpack --watch").
If i use node 10 the scrips runs perfectly but in the entire project we are using node 12 so i'm not sure what is the problem here.
i'm wonder if it could be a problem when i'll try to migrate from MUI v1 to v4 and use the modified library into my project again, or in first place, why its working rigth now?
Anyway i just wanted to know, just if i need it, Could i use different versions of node in a library and then use other newer version into the entire project?
Could this make some negatives effect into my entire project?
Which is the best way to migrate MUI into this library and put it in my project again?
Each nodejs process (including all the modules/libraries it loads) has exactly one version of nodejs running. It isn't possible to have two separate versions of nodejs in the same process each running different parts of the code.
You could make two separate nodejs apps that each run under a different version of nodejs that communicate with each other via some interprocess communication, but they have to be two separate applications/processes.
If you want to run everything in one process (on one version of nodejs), then you will need to test and fix all your libraries to run on that one version of nodejs.

Figuring out the node version of an existing Node.js Application

I have a old Node.js application that I need to rebuild it to run it using my current Node installed. I have the node_modules folder. However, I cannot figures it was created using what version of Node. I searched for the term 'engine', but I had not success. Any ideas would be greatly appreciated.
The engines property can be used to define which versions of Node your application can run on, but it is optional. Without it, there is no way of knowing what version on Node the app was developed on. You could have switched Node versions during development and if there were no breaking changes, the application would have no idea.
Something you could try to do is look at the dependencies in your node_modules/ folder - if the dependencies are the same versions that you installed when originally developing, they might have engines properties in their package.json files that you could look at and piece together a picture of what Node version the application was developed for.
If you are trying to update the app to use a modern Node version, an easy way forward is to simply run the app, see what breaks, look up documentation to see what has changed between versions, and update your code until it works as expected.
TL;DR - There is no definitive way of knowing what the Node version was when the app was developed, unless it was documented by the developer.

Node and npm specific to an angular project

I am working on an angular project(6) with node. I have some other projects already built on the lower versions of ang+node+npm.
I am trying to deploy it on to a server, Since there are different node+npm needed for different projects, facing difficulties to build them parallelly.
Tried to use nvm for the switching of nodes, but doing so the versions are getting changed globally which is not serving the purpose.
Anyone tried this already or can anyone help me on this?

Are all node modules supposed to work out of the box with react native?

I have tried using a couple of node modules with react native using npm install (specifically https://github.com/Thuzi/facebook-node-sdk/) and I continually get errors about dependencies not being resolved when I run the app. Are node modules generally supposed to be supported by react native or only modules that are specifically written for it (such as this one https://github.com/brentvatne/react-native-login).
Many Node modules will not work with React Native. Some of the reasons are architectural and can be fixed (ex: currently React Native supports only asynchronous native methods while Node supports synchronous ones as well), while others are inherent to the fact that Node runs on V8 and React Native iOS runs on JSC.
As a heuristic, you should find success with Node modules that are utilities and depend only on JavaScript's core library (the APIs defined here: https://people.mozilla.org/~jorendorff/es6-draft.html). This includes things like sorting algorithms, string formatting, etc.

Resources