Saturday, July 9, 2022

10 Powerful React Tools That You Should Know in 2022

Strorybook is something to try out. 

https://storybook.js.org/
https://javascript.plainenglish.io/10-powerful-react-tools-that-you-should-know-in-2022-76efa7fa711d

useMemo and useCallback in React

 https://medium.com/@jakobclausen/usememo-and-usecallback-in-react-913d307eb69

Friday, May 20, 2022

PM2 run different node version

To run several versions at the same time. In pm2, you can use the --interpreter options and specify the path to the node version you want.

You may install different node versions using nvm. 
Install NodeJS using Version Manager

Running direct script using PM2 process file:

module.exports = {
    apps : [{
      name   : "app1",
      cwd    : "/home/user/app1", // folder store the application
      script : "./app.js", // starting js file
      interpreter : 'node@6.9.1'    // Node version
    },
   {
      name   : "app2",
      cwd    : "/home/user/app2",
      script : "./app.js",
      interpreter : 'node@12.9.1'
   }]
}


Running using npm script using PM2 process file:

module.exports = {
    apps : [{
      name   : "app1",
      cwd    : "/home/user/app1", // folder store the application
      script : "/home/user/.nvm/versions/node/v6.9.1/bin/npm", // Folder where the npm stored
      args       : ["run", "start"],  // Argument pass to npm
      interpreter : 'node@6.9.1'    // Node version
    },
    {
       name   : "app2",
       cwd    : "/home/user/app2",
       script : "/home/user/.nvm/versions/node/v12.9.1/bin/npm",
       args       : ["run", "start"],
       interpreter : 'node@12.9.1'
    }]
}