node.js
Error with node-sass when running npm install
node-sass has been deprecated. It has been transformed to the npm package sass now. You can uninstall the old and install the new one npm uninstall node-sass npm install sass Many issues also those during installation have been fixed with this.
How to check confirm password with zod
You can achieve this by tacking on a superRefine export const registerUserSchema = z.object({ firstName: z.string(), lastName: z.string(), userName: z.string(), email: z.string().email(), phone: z.string().transform(data => Number(data)), password: z.string().min(4), confirmPassword: z.string().min(4), avatar: z.string().optional(), isVerified: z.boolean().optional() }).superRefine(({ confirmPassword, password }, ctx) => { if (confirmPassword !== password) { ctx.addIssue({ code: “custom”, message: “The passwords did not match” … Read more
How to resolve “Error: error:0308010C:digital envelope routines::unsupported” Nodejs 18 error [duplicate]
In my case this happened in my Github Actions build pipeline when I was running npm run build. I was able to fix it by providing the following environment argument: export NODE_OPTIONS=–openssl-legacy-provider According from what I have read this node option can also be set in package.json. What I did was modifying the scripts section … Read more
Puppeteer not rendering color, background color when I try to save PDF on disk
Puppeteer is just a library to drive Chrome/Chromium, so if anything goes wrong while using it, our best bet is to open Chromium with puppeteer.launch({headless:false}) and debug there. Set your page css in <style></style> tag. You can solve the issue with the following CSS code: html { -webkit-print-color-adjust: exact; } p { color: #FF0000; }
How can I use “exports” in package.json for nested submodules and TypeScript?
Node.js has supported exports since v12.7.0 (Jul. 2019) When I asked this question (Dec. 2021), NodeJS had supported the exports field for nearly 2.5 years. It seemed reasonable to assume that Typescript supported it. The latest version of TypeScript at that time (4.5) did not support the exports field. This was particularly confusing because the … Read more
Stripe Checkout example running into CORS error from localhost
Here are some of the things I learned while trying to debug this. Stripe checkout uses AWS Cloudfront and it does not allow options requests (as per Stripe’s config) OPTIONS request are not sent to Stripe when I change the request type in the frontend to text/plain. (Yes, that’s right, after my server returns the … Read more
node.js how to check a process is running by the process name?
You can use the ps-node package. https://www.npmjs.com/package/ps-node var ps = require(‘ps-node’); // A simple pid lookup ps.lookup({ command: ‘node’, psargs: ‘ux’ }, function(err, resultList ) { if (err) { throw new Error( err ); } resultList.forEach(function( process ){ if( process ){ console.log( ‘PID: %s, COMMAND: %s, ARGUMENTS: %s’, process.pid, process.command, process.arguments ); } }); }); … Read more
Where is node while using nvm?
You can get the path to the executable to where node was installed with nvm which node Or any of the other NVM special aliases for node versions such as nvm which default