Node.js ERR_OSSL_EVP_UNSUPPORTED - node.js

I'm trying to create mintable NFT and while I was using metaplex sugar i see only one thing when using command "yarn start":
opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
library: 'digital envelope routines',
reason: 'unsupported',
code: 'ERR_OSSL_EVP_UNSUPPORTED'
This is how "scripts" look like:
"scripts": {
"start": "react-scripts --openssl-legacy-provider start",,
"lint": "prettier -c 'src/**/*.{ts,tsx}' && npm run lint:eslint",
"lint:eslint": "eslint 'src/**/*.{ts,tsx}'",
"lint:fix": "prettier --write 'src/**/*.{ts,tsx}' && eslint --fix 'src/**/*.{ts,tsx}'",
"build": "craco build",
"test": "craco test",
"eject": "craco eject"
},
I tried using different versions of Nodes but nothing helped me. I tried to replace "scripts" using thhis:
"scripts": {
"start": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts start",
"build": "export SET NODE_OPTIONS=--openssl-legacy-provider && react-scripts build"
}
but it still doesn't work.

Related

How to configure lint-staged to run eslint and prettier scripts

I have this setup:
// package.json
...
"scripts": {
...
"lint": "eslint --fix {src,test}/**/*.{js,ts,jsx,tsx} --no-error-on-unmatched-pattern",
"style": "prettier --write {src,test}/**/* ./*.{json,*.json} !package-lock.json -u --no-error-on-unmatched-pattern",
...
"lint-staged": {
"lint-staged": {
"{src,test}/**/*.{js,ts,jsx,tsx}": [
"npm run lint",
"npm run style"
],
"!**/*.{js,ts,jsx,tsx}": "npm run style"
},
}
...
The problem is that prettier will run no matter what file is matched by the glob, prettier will also double run on all files and rewrite all of them twice.
You can't use double glob expressions when using lint-staged, it will cause conflicts.
// package.json
...
"scripts": {
...
"lint": "eslint --fix {src,test}/**/*.{js,ts,jsx,tsx} --no-error-on-unmatched-pattern",
"style": "prettier --write {src,test}/**/* ./*.{json,*.json} !package-lock.json -u --no-error-on-unmatched-pattern",
...
"lint-staged": {
"lint-staged": {
"{src,test}/**/*.{js,ts,jsx,tsx}": [
"eslint --fix",
"prettier --write -u"
],
"!**/*.{js,ts,jsx,tsx}": "prettier --write -u"
},
}
...
Just use prettier --write -u and eslint --fix when you're running lint-staged, don't run your custom scripts otherwise the globs with conflict with one another. Instead just run eslint and prettier directly on the glob matched by lint-staged.

eslint linting .eslintrc.js itself

I have the following scripts and eslint rules in my package.json:
"scripts": {
"build": "tsc",
"test": "jest tests/** --coverage",
"lint": "eslint './src/**/*.{js,ts,tsx}' --quiet --fix",
"prettier": "prettier --check './**/*.ts'",
"prettier-format": "prettier --config .prettierrc './**/*.ts' --write"
...
},
"lint-staged": {
"**/*.{js,jsx,ts,tsx}": [
"prettier --config .prettierrc './**/*.ts' --write",
"prettier --check './**/*.ts'",
"eslint './src/**/*.{js,ts,tsx}' --quiet --fix"
]
},
"pre-commit": [
"lint-staged"
],
When I run npm run lint I do not get any errors. But when my pre-commit hook runs, I get an error on the .eslintrc.js file:
/.../api/.eslintrc.js
1:15 error Require statement not part of import statement #typescript-eslint/no-var-requires
The line of code it's referencing has the following:
const _path = require('path');
I know I can instrument the code to force eslint to ignore this. But I do not understand why eslint is parsing .eslintrc.js in the first place as it is not located in the src folder (it's on the root folder on the same level of package.json).

env.NODE_ENV always returns the default value in REACT APP

Try 1:
"scripts": {
"start": "react-scripts start",
"build": "set REACT_APP_STAGE=dev && react-scripts build",
"test": "react-scripts test",
}
Try 2:
"scripts":
"start": "react-scripts start",
"build": "NODE_ENV=dev&&react-scripts build",
"test": "react-scripts test"
}
//Also tried with and without space
Script,
export const configuration = process.env.NODE_ENV === 'production'
? prod
: dev;
Always returns development locally and production in pipeline
I know there are so many question I have tried all the combination it never helped.

How to fix this frequent 'Failed to parse json' problem with npm?

I have a frequent problem with npm, it occurs when running npm start command in a react project folder after some time not working with that project.
I get several lines of log include 'Failed to parse json' and 'package.json must be actual JSON, not just Javascript'.
The problem always happen after i get to deal with the project after some weeks of no-use, my package.json file seems fine and this is an example
{
"name": "carzyGame",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^16.4.2",
"react-dom": "^16.4.2",
"react-scripts": "1.1.4",
"redux": "^4.0.0",
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
}
}
another one:
{
"name": "neighborhood",
"version": "0.1.0",
"private": true,
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
"dependencies": {
"escape-string-regexp": "^1.0.5",
"react": "^16.4.1",
"react-dom": "^16.4.1",
"react-foursquare": "^1.0.3",
"react-scripts": "1.1.4",
"sort-by": "^1.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
I tried to uninstall npm by npm uninstall and i got the same error, also removing node modules file could not help (the purpose is to re-install it).
So what is the reason of that problem and how to solve it?
The faulty lines are:
"redux": "^4.0.0",
"eject": "react-scripts eject",
Unlike in JavaScript, a trailing comma is not allowed in the last key-value pair of a JSON object.

Set Electron favicon with electron-builder

I would like set new favicon in my Electron App and replace default Electron icon when my app is build.
I use electron-builder package. In the doc, i see the icons need to be placed in the build directory. So :
And when i build my app, i've this message :
Application icon is not set, default Electron icon will be used.
Anyone can help me ?
Part of my package.json :
"scripts": {
"postinstall": "install-app-deps && npmpd",
"pre-build": "./node_modules/.bin/electron-rebuild",
"build-bcrypt": "npm rebuild bcrypt --update-binary",
"develop": "npm run private:compile -- --source-maps true && run-p -r private:watch private:serve",
"test": "mocha -R spec --compilers js:babel-core/register test/**/*.spec.js",
"lint": "eslint --no-ignore scripts app test *.js",
"pack": "run-s private:clean private:compile private:build:all",
"pack:mac": "run-s private:clean private:compile private:build:mac",
"pack:win": "run-s private:clean private:compile private:build:win",
"pack:linux": "run-s private:clean private:compile private:build:linux",
"private:build:all": "build -mwl",
"private:build:mac": "build --mac",
"private:build:win": "build --win",
"private:build:linux": "build --linux",
"private:watch": "npm run private:compile -- --source-maps true --watch --skip-initial-build",
"private:serve": "babel-node scripts/serve.js",
"private:compile": "babel app/ --copy-files --out-dir build",
"private:clean": "rimraf build",
"private:cleandb": "rm -rf ./categories ./presentations ./slides ./users"
},
"build": {
"win": {
"icon": "build/icon.ico"
}
}
In package.json, under the win key, you also need to specify the icon path:
"build": {
"win": {
"icon": "build/app.ico"
}
}
Had similar issue, i added directories to my build
"build":{
"directories": {
"buildResources": "resources"
}
}
and inside the directories folder i had my icon.ico file
I encounter same issue with you, since I also use build directory for my output, here is my configuration:
"build": {
"directories":{
"output": "build"
},
"mac": {
"icon": "build/logo.icns",
},
"win": {
"icon": "build/logo.png"
}
},
instead of specifying your directory such as ./logo.png which make electron shows default Electron icon is used reason=application icon is not set
I managed to have my icon on windows with the following script in package.json:
"package-win": "electron-packager . --overwrite --asar=true --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=Company --version-string.FileDescription=CE --version-string.ProductName=\"Product\""

Resources