npm install error in Bitbucket CI/CD pipeline - node.js

I have a pipeline set up for my Bitbucket repository that runs npm install if there is no node cache. Up until now it has worked fine, but the node cache was recently cleared, and now I'm getting the following output from Bitbucket (Pastebin link, due to character limit): https://pastebin.com/fY9TznNn
package.json:
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"#types/geojson": "^7946.0.7",
"#types/google-libphonenumber": "^7.4.19",
"#types/google-map-react": "^2.1.0",
"#types/jest": "^24.0.0",
"#types/node": "^12.12.55",
"#types/react": "^16.9.49",
"#types/react-bootstrap": "^0.32.22",
"#types/react-dom": "^16.9.8",
"#types/react-modal": "^3.10.6",
"#types/react-router-dom": "^5.1.5",
"#types/supercluster": "^5.0.2",
"axios": "^0.21.1",
"bootstrap": "^4.5.2",
"enzyme": "^3.11.0",
"eslint": "^6.8.0",
"firebase": "^7.24.0",
"geojson": "^0.5.0",
"google-libphonenumber": "^3.2.14",
"google-map-react": "^2.1.3",
"node-sass": "^4.0.0",
"react": "^16.13.1",
"react-async": "^10.0.1",
"react-bootstrap": "^1.3.0",
"react-cool-img": "^1.2.4",
"react-dom": "^16.13.1",
"react-dropzone": "^11.3.2",
"react-modal": "^3.12.1",
"react-router-dom": "^5.2.0",
"react-scripts": "^3.4.4",
"supercluster": "^7.1.0",
"typescript": "^3.2.1",
"use-supercluster": "^0.2.9"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "npx prettier --write src && npx eslint src --fix --ext .ts --ext .tsx"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/enzyme": "^3.10.8",
"#types/enzyme-adapter-react-16": "^1.0.6",
"#typescript-eslint/eslint-plugin": "^3.10.1",
"#typescript-eslint/parser": "^3.10.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"eslint": "^7.23.0",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsx-a11y": "^6.3.1",
"eslint-plugin-promise": "^4.3.1",
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"eslint-plugin-sort-keys-fix": "^1.1.1",
"prettier": "^2.1.1"
}
}
bitbucket-pipelines.yml:
image: node
definitions:
steps:
- step: &lint
name: Check code style
script:
- npm install # this is where the error occurs
- npx eslint **/*.ts[x]
caches:
- node
- step: &build
name: Build and test
script:
- echo > ".env"
- echo REACT_APP_GOOGLE_API_KEY=$GOOGLE_API_KEY >> ".env"
- echo REACT_APP_HANDSHAKE_API_KEY=$HANDSHAKE_API_KEY >> ".env"
- npm install
- npm run test
- npm run build
artifacts:
- build/**
caches:
- node
- step: &deploy
name: Deploy to Firebase
script:
- cd functions
- npm install
- cd ..
- pipe: atlassian/firebase-deploy:1.0.0
variables:
FIREBASE_TOKEN: $FIREBASE_TOKEN
PROJECT_ID: $FIREBASE_PROJECT
pipelines:
pull-requests:
"**":
- step: *lint
- step: *build
branches:
master:
- step: *lint
- step: *build
- step: *deploy
I'm concerned it might have something to do with the node-sass package as I've experienced issues with it before, and it's the first dependency to appear in the error. But I'm really not sure how to interpret this output or how to fix it. Thanks for any help!

Looks like my intuition was right—it was because of the node-sass package. Apparently it's deprecated. Installing sass instead fixed the problem!

Related

Override for react-error-overlay#^6.0.9 conflicts with direct dependency

I have changed my node version and keep getting this error if I try to install another package or just try to run npm install. Here is the error message:
npm ERR! code EOVERRIDE
npm ERR! Override for react-error-overlay#^6.0.9 conflicts with direct dependency
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\admin\AppData\Local\npm-cache_logs\2022-12-08T16_39_09_063Z-debug-0.log`
My package.json file is below:
{
"name": "kamamini",
"version": "0.1.0",
"author": "Moctar Yonli",
"private": true,
"dependencies": {
"#ckeditor/ckeditor5-build-classic": "^28.0.0",
"#ckeditor/ckeditor5-build-decoupled-document": "^28.0.0",
"#ckeditor/ckeditor5-react": "^3.0.2",
"#emotion/react": "^11.5.0",
"#emotion/styled": "^11.3.0",
"#firebase/auth-interop-types": "^0.1.5",
"#glidejs/glide": "^3.5.2",
"#material-ui/core": "^4.11.3",
"#material-ui/icons": "^4.11.2",
"#metismenu/react": "0.0.2",
"#mui/icons-material": "^5.0.5",
"#mui/material": "^5.0.6",
"#mui/styles": "^5.0.2",
"#testing-library/jest-dom": "^5.11.9",
"#testing-library/react": "^11.2.5",
"#testing-library/user-event": "^12.7.1",
"axios": "^0.24.0",
"bootstrap": "^5.1.3",
"dotenv": "^10.0.0",
"firebase": "^8.4.1",
"formik": "^2.2.9",
"framer-motion": "^4.1.17",
"gh-pages": "^3.2.3",
"history": "^5.0.1",
"moment": "^2.29.4",
"node-sass": "^7.0.1",
"perfect-scrollbar": "^1.5.2",
"react": "^17.0.1",
"react-confetti": "^6.1.0",
"react-currency-format": "^1.1.0",
"react-dom": "^17.0.1",
"react-dropzone": "^11.3.2",
"react-helmet-async": "^1.3.0",
"react-html-parser": "^2.0.2",
"react-image-gallery": "^1.0.9",
"react-material-ui-carousel": "^2.2.6",
"react-payment-inputs": "^1.1.9",
"react-player": "^2.9.0",
"react-redux": "^7.2.4",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.3",
"react-share": "^4.4.0",
"react-slick": "^0.28.1",
"react-swipeable-views": "^0.14.0",
"react-toastify": "^7.0.3",
"react-use": "^17.4.0",
"reactstrap": "^8.9.0",
"redux": "^4.1.0",
"redux-thunk": "^2.3.0",
"slick-carousel": "^1.8.1",
"styled-components": "^5.3.3",
"web-vitals": "^1.1.0",
"yup": "^0.32.9"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"``eslintConfig``": {
"extends": [
"react-app",
"react-app/jest"
]
},
"`browserslist`": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"overrides": {
"react-error-overlay": "6.0.9"
},
"devDependencies": {
"react-error-overlay": "^6.0.9"
}
}
Why do I get this error when trying to install a package?
As per the docs
You may not set an override for a package that you directly depend on unless both the dependency and the override itself share the exact same spec.
Your override for react-error-overlay specifies 6.0.9 (i.e. the exact version), while your devDependencies specifies ~6.0.9 (i.e. match 6.0.9 or any patch release above). These specs are not exactly the same, so you get the error.
You can fix it by:
updating your overrides to use ~6.0.9
updating your devDependencies to use 6.0.9
updating your overrides to use "react-error-overlay": "$react-error-overlay" which tells it to use the version referenced in the dependencies directly
To make this limitation easier to deal with, overrides may also be defined as a reference to a spec for a direct dependency by prefixing the name of the package you wish the version to match with a $.
You just have to remove the overrides section of your package.json file.

ERR! code E401 npm ERR! Incorrect or missing password

I am trying to do an "npm install" on my project which I have checked out and I have recieved this error :
npm WARN deprecated core-js#2.6.11: core-js#<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
I have done a number of things.
removed all .npmrc files on my file system.
logged in as my npm user
deleted package-lock.json
..but i still get the same error.
At the end of the day what I would really like to know is, WHY am I getting this error? Why when I install all my modules does it suddenly want me to log in? Is this from a particular module? What is the reasoning behind this error?
If I "npm install" a random react project I have no problems, so I guess there is something wrong in my package.json. But WHAT module is it?
I am at a complete loss.
My package.json looks like this :
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"#fortawesome/fontawesome-svg-core": "^1.2.28",
"#fortawesome/free-solid-svg-icons": "^5.13.0",
"#fortawesome/react-fontawesome": "^0.1.9",
"#material-ui/core": "^4.11.4",
"#material-ui/icons": "^4.11.2",
"#stripe/react-stripe-js": "^1.1.2",
"#stripe/stripe-js": "^1.5.0",
"#testing-library/jest-dom": "^4.2.4",
"#testing-library/react": "^9.3.2",
"#testing-library/user-event": "^7.1.2",
"#types/node": "^16.0.1",
"#types/react": "^17.0.14",
"#types/react-dom": "^17.0.9",
"apisauce": "^1.0.1",
"formik": "^2.1.4",
"history": "^4.10.1",
"jwt-decode": "^2.2.0",
"moment": "^2.27.0",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-redux": "^7.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.1",
"react-toastify": "^7.0.4",
"redux": "4.0.1",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"typescript": "^4.3.5"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test-c": "jest --coverage",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"#types/jest": "^25.2.3",
"#types/jwt-decode": "^3.1.0",
"#types/react-redux": "^7.1.17",
"#types/react-router": "^5.1.16",
"#types/react-router-dom": "^5.1.8",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.2",
"flow-bin": "^0.152.0",
"jest-serializer-html": "^7.0.0",
"react-test-renderer": "^16.13.1",
"redux-mock-store": "^1.5.4"
}
}

CircleCI is not running 'npm run' commands

I'm facing issues implementing a CI/CD pipeline with CircleCI. I'm not able to execute any 'npm run' commands in the pipeline whereas these commands run on my local system.
I have built an Angular Client and Node/ Express API. And my folder structure is setup in the following way.
- .circleci
-- config.yml
- client
- server
- package.json
In the pipeline 'cd client npm install' works whereas 'cd client npm run build' does not work. My Angular project has 'build' script with the command set to 'ng build'.
But still the log in CircleCI reads 'npm ERR! Missing script: "build"'
The same is the case with my server folder commands. Another interesting thing to note is if I create a script named 'installapp' and use the command 'npm install' as its value, the log will now read 'npm ERR! Missing script: "installapp"'. So 'npm install' works but not 'npm run installapp' even though they both finally execute 'npm install'.
Can someone please help me resolve this issue? I'm sharing my config.yml and all the package.json files for reference to help solve this error.
.circleci/config.yml
version: 2.1
orbs:
node: circleci/node#4.1.0
aws-cli: circleci/aws-cli#1.3.1
jobs:
build:
docker:
- image: "cimg/base:stable"
steps:
- node/install
- checkout
- aws-cli/setup
- run:
name: Front-End Install
command: |
npm run frontend:install
- run:
name: Back-End Install
command: |
npm run backend:install
- run:
name: Front-End Build
command: |
npm run frontend:build
- run:
name: Back-End Build
command: |
npm run backend:build
- run:
name: Deploy App
command: |
npm run frontend:deploy
npm run backend:deploy
Root application's package.json
{
"scripts": {
"frontend:install": "cd client && npm install",
"backend:install": "cd server && npm install",
"frontend:build": "cd client && npm run build",
"backend:build": "cd server && npm run build",
"frontend:deploy": "cd client && npm run deploy",
"backend:deploy": "cd server && npm run deploy"
}
}
client package.json (Angular)
{
"name": "guitar-store-app",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint",
"deploy": "chmod +x ./bin/deploy.sh && ./bin/deploy.sh"
},
"private": true,
"dependencies": {
"#angular/animations": "~12.2.0",
"#angular/common": "~12.2.0",
"#angular/compiler": "~12.2.0",
"#angular/core": "~12.2.0",
"#angular/forms": "~12.2.0",
"#angular/platform-browser": "~12.2.0",
"#angular/platform-browser-dynamic": "~12.2.0",
"#angular/router": "~12.2.0",
"#auth0/angular-jwt": "^5.0.2",
"rxjs": "~6.6.0",
"tslib": "^2.3.0",
"w3-css": "^4.1.0",
"zone.js": "~0.11.4"
},
"devDependencies": {
"#angular-devkit/build-angular": "~12.2.1",
"#angular-eslint/builder": "12.3.1",
"#angular-eslint/eslint-plugin": "12.3.1",
"#angular-eslint/eslint-plugin-template": "12.3.1",
"#angular-eslint/schematics": "12.3.1",
"#angular-eslint/template-parser": "12.3.1",
"#angular/cli": "~12.2.1",
"#angular/compiler-cli": "~12.2.0",
"#types/jasmine": "~3.8.0",
"#types/node": "^12.11.1",
"#typescript-eslint/eslint-plugin": "4.28.2",
"#typescript-eslint/parser": "4.28.2",
"eslint": "^7.26.0",
"jasmine-core": "~3.8.0",
"karma": "~6.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.0.3",
"karma-jasmine": "~4.0.0",
"karma-jasmine-html-reporter": "~1.7.0",
"typescript": "~4.3.5"
}
}
server package.json (Node/Express)
{
"name": "storefront-backend-api",
"version": "1.0.0",
"description": "An e-commerce API",
"main": "build/server/app.js",
"engines": {
"node": ">=14.17.1",
"npm": ">=6.14.13"
},
"scripts": {
"lint": "eslint src/**/*.ts",
"prettier": "prettier --config .prettierrc src/**/*.ts --write",
"build": "npx tsc",
"jasmine": "jasmine",
"test-local": "set ENV=test&& db-migrate db:create guitar_shop_test && db-migrate --env test up && npm run jasmine && db-migrate db:drop guitar_shop_test",
"start": "node build/server/app.js",
"deploy": "chmod +x ./bin/deploy.sh && ./bin/deploy.sh"
},
"repository": {
"type": "git",
"url": "git+https://github.com/siddube/full-stack-app-server.git"
},
"keywords": [
"Image",
"Resize"
],
"author": "siddube",
"license": "ISC",
"bugs": {
"url": "https://github.com/siddube/full-stack-app-server/issues"
},
"homepage": "https://github.com/siddube/full-stack-app-server#readme",
"devDependencies": {
"#types/bcrypt": "^5.0.0",
"#types/cors": "^2.8.12",
"#types/express": "^4.17.12",
"#types/jasmine": "^3.7.7",
"#types/jsonwebtoken": "^8.5.4",
"#types/node": "^16.0.0",
"#types/pg": "^8.6.1",
"#types/supertest": "^2.0.11",
"#types/underscore": "^1.11.3",
"#typescript-eslint/eslint-plugin": "^4.28.2",
"#typescript-eslint/parser": "^4.28.2",
"db-migrate-pg": "^1.2.2",
"dotenv": "^10.0.0",
"eslint": "^7.30.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^3.4.0",
"jasmine-ts": "^0.4.0",
"nodemon": "^2.0.13",
"prettier": "^2.3.2",
"ts-node": "^10.0.0",
"typescript": "^4.3.5"
},
"dependencies": {
"bcrypt": "^5.0.1",
"cors": "^2.8.5",
"db-migrate": "^1.0.0-beta.16",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"jasmine": "^3.8.0",
"jasmine-spec-reporter": "^7.0.0",
"jsonwebtoken": "^8.5.1",
"pg": "^8.7.1",
"supertest": "^6.1.5",
"underscore": "^1.13.1"
},
"eslintIgnore": [
"**/*[sS]pec.ts",
"reporter.ts"
]
}
I think the main issue is I am not able to run 'npm run' scripts defined in these files. When the log prompts me to check available npm run commands, all these commands do show up. And 'npm install' works fine.
Would really appreciate some help or suggestions to solve this. Thanks!
I apologise, but this is a real CircleCI rookie mistake. My client and server folders were git repositories themselves and the root app would create empty folders for them while instantiating the pipeline. Solved it by creating two new folders and copying files without the old git repositories and it is working fine.
In my defense this was the first time I'm implementing a CI/CD pipeline.

Husky Hook does not work properly with Test

I'm configuring Husky to block commits if the prettier or eslint accuses both an error or warn, and block the push if it doesn't pass the tests.
However, when running the test, the test CLI is displayed (it is in the image below), with this, no key works, but I can only finish by clicking with the shortcut ctrl+z, which suspends my push.
MY CODE IN .HUSKY FOLDER:
pre-commit
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn prettier-check
yarn lint-check
pre-push
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
yarn test
MY PACKAGE.JSON:
{
"name": "web-whatsapp",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"prettier-check": "prettier --check 'src/**/*.{ts,tsx}'",
"prettier-fix": "prettier --write 'src/**/*.{ts,tsx}'",
"lint-check": "eslint 'src/**/*.{ts,tsx}'",
"lint-fix": "eslint --fix 'src/**/*.{ts,tsx}'",
"prepare": "husky install"
},
"dependencies": {
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"#types/jest": "^26.0.15",
"#types/node": "^12.0.0",
"#types/react": "^17.0.0",
"#types/react-dom": "^17.0.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-scripts": "4.0.3",
"styled-components": "^5.2.3",
"typescript": "^4.1.2",
"web-vitals": "^1.0.1"
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^4.22.0",
"#typescript-eslint/parser": "^4.22.0",
"eslint": "^7.24.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.2.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jest": "^24.3.5",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-react": "^7.23.2",
"eslint-plugin-react-hooks": "^4.2.0",
"eslint-plugin-testing-library": "^4.0.1",
"husky": "^6.0.0",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Well, what I had to do was this ..
Install the cross-env library in development mode. This library causes the terminal to clear the buffer at the end of the test run in order to continue with the pre-push Hook.
I inserted the following in the "test" scripts:
"test": "cross-env CI = true react-scripts test --passWithNoTests"
About CI = true
This environment variable, short for Continuous Integration, is commonly defined in various CI environments, such as Travis CI and Github Actions, among many others.
NOTE
Do not use the --watchAll flag, as it will "lock" the terminal.

Getting issues while installing React Project on Windows system

I am trying to install a React Web Application on my Windows system. It was working fine earlier but when I re-installed my Windows then it stopped working. I have already installed Node and Npm.
When I run the command npm install it goes well. But when I run the command npm start it throws the following error:
REACT_APP_ENV is not recognized as an internal or external command
Please see the attached image also:
I have tried a lot to find and fix the issue but nothing worked.
Here is package.json file content:
{
"name": "wm-webapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"gapi-client": "0.0.3",
"libphonenumber-js": "^1.7.7",
"moment": "^2.24.0",
"node-sass": "^4.11.0",
"react": "^16.7.0",
"react-bootstrap": "^0.32.4",
"react-dates": "^18.4.1",
"react-dom": "^16.7.0",
"react-facebook-login": "^4.1.1",
"react-google-login": "^5.0.0",
"react-places-autocomplete": "^7.2.0",
"react-redux": "^5.0.7",
"react-responsive": "^6.1.1",
"react-router": "^4.3.1",
"react-router-dom": "^4.3.1",
"react-router-redux": "^5.0.0-alpha.9",
"react-scripts": "2.1.3",
"react-select": "^1.2.1",
"react-stripe-elements": "^2.0.2",
"react-table": "^6.8.6",
"react-toastify": "^4.5.2",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.7",
"redux-form": "^8.1.0",
"redux-form-input-masks": "^1.3.0",
"redux-logger": "^3.0.6",
"redux-saga": "^1.0.0",
"redux-thunk": "^2.3.0",
"store": "^2.0.12",
"styled-components": "^4.1.3"
},
"scripts": {
"start:env": "env-cmd .env.${REACT_APP_ENV} react-scripts start",
"start": "REACT_APP_ENV=dev npm run start:env",
"start:test": "REACT_APP_ENV=test npm run start:env",
"build:env": "env-cmd .env.${REACT_APP_ENV} react-scripts build",
"build": "REACT_APP_ENV=test npm run build:env",
"build:prod": "REACT_APP_ENV=prod npm run build:env",
"test": "react-scripts test",
"eject": "react-scripts eject",
"deploy": "aws s3 cp build s3://test.washmix.com/ --recursive --profile washmix",
"format": "prettier --write --single-quote --tab-width=2 --print-width=80"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"devDependencies": {
"axios-mock-adapter": "^1.16.0",
"env-cmd": "^8.0.2",
"husky": "^1.3.1",
"prettier": "^1.16.1"
}
}
Already late to answer but for people searching for the answer..
For Windows (cmd.exe) :
'set "REACT_APP_ENV=dev" && npm run start'
For Windows (Powershell) :
'($env:REACT_APP_ENV = "dev") -and (npm start)'
For Linux, macOS (Bash) :
'REACT_APP_ENV=dev npm start'
You can anytime get thing variable with process.env.REACT_APP_ENV
You must change all environment variables in your package.json for:
Set NAME_VARIABLE=VALUE
Ex:
"start": "Set REACT_APP_ENV=dev&& npm run start:env",
If you're running on windows, remember to leave no space between the commands and &&.
So the start script will be :
"start-staging":"set REACT_APP_ENV=staging&&react-scripts start"
In script-> start, write cross-env in starting of the value.
After that
Run: npm install.
And you are ready to go

Resources