Failed to load config "airbnb" to extend from - gitlab ci - gitlab-ci

I tried to do and redo the Airbnb eslint installation in various ways, but I always get this build error inside GitLab-ci. It works in my local environment.
I created the project with the create-react-app, installed the dependencies separately so as not to overwrite the eslint version. But I've tried to install all dependencies together using npx install-peerdeps --dev eslint-config-airbnb and reinstalling the version of eslint created by creating react app.
I've also tried to set dependencies directly in package.json instead of creating a configuration file
My package.json:
{
"name": "assinatura",
"version": "0.1.0",
"private": true,
"dependencies": {
"#emotion/react": "^11.4.1",
"#emotion/styled": "^11.3.0",
"#mui/material": "^5.0.2",
"#react-pdf-viewer/core": "^2.9.1",
"#react-pdf-viewer/page-navigation": "^2.9.1",
"#react-pdf-viewer/zoom": "^2.9.1",
"axios": "^0.21.4",
"bootstrap": "^5.0.2",
"enzyme-to-json": "^3.6.2",
"pdfjs-dist": "2.6.347",
"progress-bar": "^0.1.1",
"prop-types": "^15.7.2",
"query-string": "^7.0.1",
"react": "^17.0.2",
"react-bootstrap": "^2.0.0-rc.0",
"react-dom": "^17.0.2",
"react-icons": "^4.2.0",
"react-meta-tags": "^1.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.3",
"react-signature-canvas": "^1.0.3",
"styled-components": "^5.3.1",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:coverage": "react-scripts test --coverage",
"eject": "react-scripts eject",
"postinstall": "node ./postconfig.js",
"eslint": "eslint .",
"eslint-fix": "eslint --fix .",
"build:staging": "sh -ac '. ./.env.staging; react-scripts build'"
},
"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"
]
},
"devDependencies": {
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "^2.4.1"
}
}
My .eslintrc:
{
"extends": [
"react-app",
"airbnb",
"plugin:jsx-a11y/recommended",
"prettier"
],
"plugins": [
"jsx-a11y",
"prettier"
],
"rules": {
"semi": 0,
"prettier/prettier": [
"error", {
"semi": false
}
]
}
}
and I put node_modules on .eslintignore
Has anyone ever experienced this?

I had a similar issue on a react app while deploying through GitHub and was code built.
npm install -g install-peerdeps
install-peerdeps --dev eslint-config-airbnb
install-peerdeps --dev eslint-config-airbnb-base
Will fix it for you too

In your .eslintrc or where your eslint config is,
look for the extends object and remove the "airbnb" from the array if it is not needed.
from ==> "extends": ["airbnb", "prettier", "plugin:react/jsx-runtime", "plugin:jsx-a11y/recommended", "plugin:react-hooks/recommended"],
to ==> "extends": ["prettier", "plugin:react/jsx-runtime", "plugin:jsx-a11y/recommended", "plugin:react-hooks/recommended"],
OR install the packages
npm install -g install-peerdeps install-peerdeps --dev eslint-config-airbnb install-peerdeps --dev eslint-config-airbnb-base

"eslintConfig": {
"extends": [
"react-app",
"react-app/test"
]
},

These Command-Line worked for me
rm -rf node_modules
sudo npm install eslint --save
sudo npm install eslint-config-airbnb-base --save
sudo npm install eslint-plugin-markdown --save
sudo npm install eslint-plugin-import --save
npm i
npx eslint --version

Related

How to fix `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync

I've tried pretty much everything I can find on google including npm i, deleting package.lock and running npm i again, re-cloning the project, changing the buildback, specifying previous node versions.
I keep getting this error. How can I resolve it?
`npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
remote: npm ERR!
remote: npm ERR! Missing: typescript#4.7.4 from lock file
I don't see that dependency listed anywhere in my project.
here is my main package.json file inside my client dir:
{
"name": "hello",
"version": "0.1.0",
"engines": {
"node": "16.x",
"npm": "8.x"
},
"private": true,
"dependencies": {
"#chakra-ui/icons": "^1.1.1",
"#chakra-ui/react": "^1.8.1",
"#chec/commerce.js": "^2.8.0",
"#emotion/react": "^11.7.1",
"#emotion/styled": "^11.6.0",
"#inlightmedia/react-countdown-timer": "^1.1.2",
"#nilevia/count-down-timer-react": "^1.0.4",
"#paypal/react-paypal-js": "^7.6.0",
"#react-firebase/database": "^0.3.11",
"#stripe/react-stripe-js": "^1.7.2",
"#stripe/stripe-js": "^1.29.0",
"#testing-library/jest-dom": "^5.16.1",
"#testing-library/react": "^12.1.2",
"#testing-library/user-event": "^13.5.0",
"add2calendar": "^1.1.7",
"axios": "^0.25.0",
"ethers": "^5.5.4",
"firebase": "^9.7.0",
"formik": "^2.2.9",
"framer-motion": "^5.6.0",
"hamburger-react": "^2.4.1",
"moralis": "^1.3.1",
"ngrok": "^4.3.1",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-google-places-autocomplete": "^3.4.0",
"react-icons": "^4.3.1",
"react-moralis": "^1.3.1",
"react-open-app": "^1.0.3",
"react-responsive-carousel": "^3.2.23",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.0",
"react-slick": "^0.28.1",
"react-timer-hook": "^3.0.5",
"react-toastify": "^8.2.0",
"stripe": "^8.194.0",
"use-react-countdown": "^1.0.4",
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"ngrok": "ngrok"
},
"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"
]
}
}
here is one package.json file in my ethers dir:
{
"name": "smart_constracts",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "harleauxcarrera",
"license": "ISC",
"devDependencies": {
"#nomiclabs/hardhat-ethers": "^2.0.4",
"#nomiclabs/hardhat-waffle": "^2.0.2",
"chai": "^4.3.6",
"ethereum-waffle": "^3.4.0",
"ethers": "^5.5.4",
"hardhat": "^2.8.3"
}
}
And here is one package.json at the root of my project dir :
{
"dependencies": {
"#chakra-ui/react": "^1.8.1",
"#chec/commerce.js": "^2.8.0",
"#emotion/react": "^11.7.1",
"#emotion/styled": "^11.6.0",
"#openzeppelin/contracts": "^4.4.2",
"framer-motion": "^5.6.0",
"react-dom": "^17.0.2",
"react-helmet": "^6.1.0",
"react-open-app": "^1.0.3",
"react-scripts": "^5.0.0",
"use-react-countdown": "^1.0.4"
},
"scripts": {
"start": "npm start --prefix client"
}
}
Here are the build packs I am using :
https://github.com/timanovsky/subdir-heroku-buildpack
https://github.com/heroku/heroku-buildpack-nodejs
and here is the buildpack output:
Building on the Heroku-20 stack
remote: -----> Using buildpacks:
remote: 1. https://github.com/timanovsky/subdir-heroku-buildpack
remote: 2. https://github.com/heroku/heroku-buildpack-nodejs
remote: -----> Subdir buildpack app detected
remote: -----> Subdir buildpack in client
remote: creating cache: /tmp/codon/tmp/cache
remote: created tmp dir: /tmp/codon/tmp/cache/subdirXYvgi
remote: moving working dir: client to /tmp/codon/tmp/cache/subdirXYvgi
remote: cleaning build dir /tmp/build_155f5cac
remote: copying preserved work dir from cache /tmp/codon/tmp/cache/subdirXYvgi to build dir /tmp/build_155f5cac
remote: cleaning tmp dir /tmp/codon/tmp/cache/subdirXYvgi
remote: -----> Node.js app detected
remote:
remote: -----> Creating runtime environment
remote:
remote: NPM_CONFIG_PRODUCTION=false
remote: NPM_CONFIG_LOGLEVEL=error
remote: NODE_VERBOSE=false
remote: NODE_ENV=production
remote: NODE_MODULES_CACHE=true
I was previoulsy using this buildpack:
https://github.com/mars/create-react-app-buildpack.git
for create-react-app but the terminal stated it had reached it's end of life so I had to switch it out for :https://github.com/heroku/heroku-buildpack-nodejs
I run to your issue when I was searching for answer to mine anyway, I just deleted the package-lock.json file and tried to deploy it again and it worked

RN - Could not find a declaration file for module vendor/react-native-vector-icons

I am using expo 34.0.1 for react native development. I am using TypeScript for the project and running tsc --project . --noEmit in a testing script with jest. That leads to the following error:
node_modules/#expo/vector-icons/build/createIconSet.d.ts:2:55 - error
TS7016: Could not find a declaration file for module
'./vendor/react-native-vector-icons/lib/create-icon-set'.
'../node_modules/#expo/vector-icons/build/vendor/react-native-vector-icons/lib/create-icon-set.js'
implicitly has an 'any' type.
2 export { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from
'./vendor/react-native-vector-icons/lib/create-icon-set';
Found 1 error.
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! # tsc-test: tsc
--project . --noEmit npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the # tsc-test script. npm ERR! This is probably not a problem with
npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in: npm ERR!
/Users/.npm/_logs/2019-08-31T19_25_49_598Z-debug.log
tsconfig.json:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"module": "es6",
"target": "es6",
"lib": ["es2016", "esnext.asynciterable"],
"jsx": "react-native",
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"types": ["jest"],
"moduleResolution": "node",
"allowJs": false,
"esModuleInterop": true
},
"exclude": ["node_modules"]
}
package.json
{
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"test": "npm run tslint && npm run tsc-test && npm run jest",
"tslint": "tslint --project .",
"tsc-test": "tsc --project . --noEmit",
"jest": "jest"
},
"dependencies": {
"#types/enzyme": "^3.10.3",
"expo": "^34.0.1",
"moment": "^2.24.0",
"react": "16.9.0",
"react-dom": "^16.9.0",
"react-moment": "^0.9.2",
"react-native": "https://github.com/expo/react-native/archive/sdk-34.0.0.tar.gz",
"react-native-elements": "^1.1.0",
"react-native-gesture-handler": "~1.3.0",
"react-native-reanimated": "~1.1.0",
"react-native-vector-icons": "^6.6.0",
"react-native-web": "^0.11.4",
"react-navigation": "^3.12.1"
},
"devDependencies": {
"#types/expo": "^32.0.13",
"#types/jest": "^24.0.18",
"#types/react": "^16.9.2",
"#types/react-test-renderer": "^16.9.0",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"jest": "^24.9.0",
"jest-expo": "^34.0.1",
"react-test-renderer": "^16.9.0",
"ts-jest": "^24.0.2",
"tslint": "^5.19.0",
"tslint-config-airbnb": "^5.11.1",
"typescript": "^3.5.3"
},
"private": true,
"jest": {
"preset": "jest-expo",
"transform": {
"^.+\\.js$": "<rootDir>/node_modules/react-native/jest/preprocessor.js",
"^.+\\.tsx?$": "ts-jest"
},
"testMatch": [
"**/__tests__/**/*.ts?(x)",
"**/?(*.)+(spec|test).ts?(x)"
],
"moduleFileExtensions": [
"js",
"ts",
"tsx"
],
"globals": {
"ts-jest": {
"tsConfig": {
"jsx": "react"
}
}
},
"setupFilesAfterEnv": [
"./src/setupTests.js"
]
}
}
Any ideas how to solve that?
Step 1:
Inside the "scripts" object in your package.json simply add:
"postinstall": "npx typesync"
The benefit of using npx here is that it doesn't require you to install anything on your machine.
Step 2:
Run yarn or npm install to effectively run the 'postinstall' script.
Once all your missing packages are added, you'll get a list of all the new typings to be added to your project
It may look something like this:
📦 yourAppNameHere — package.json (4 new typings added, 0 unused typings removed)
├─ + #types/babel__core
├─ + #types/react-native-vector-icons
├─ + #types/react
Step 3:
You will likely be asked to run npm install or yarn again, which will install the packages added and you will be good to go!
I can see that you are using eslint. So, it is safe to edit your compiler options and add
"noImplicitAny": false,
this will silence your error. And eslint will catch any implicit any in your code.
I hope this is correct from my understanding :-)

Persistent Jest Error: Requires Babel "^7.0.0-0", but was loaded with "6.26.3"

I am getting a persistent Jest error whenever I use npm to install my dependencies on the server side. Using yarn to install the same dependencies works, but I am currently working on a team where we're all using npm. I have tried all of the proposed solutions on Stack Overflow, upvoted or not, and none have worked for me. The two senior devs I've asked so far don't think there is anything in my globally installed npm packages that would cause this.
I get this error for every Jest test suite I run:
● Test suite failed to run
Requires Babel "^7.0.0-0", but was loaded with "6.26.3". If you are sure you have a compatible version of #babel/core, it is likely that something in your build process is loading the wrong version. Inspect the stack trace of this error tolook for the first entry that doesn't mention "#babel/core" or "babel-core" to see what is calling Babel.
at throwVersionError (node_modules/#babel/helper-plugin-utils/lib/index.js:65:11)
at Object.assertVersion (node_modules/#babel/helper-plugin-utils/lib/index.js:13:11)
at _default (node_modules/#babel/plugin-proposal-decorators/lib/index.js:35:7)
at node_modules/#babel/helper-plugin-utils/lib/index.js:19:12
at Function.memoisePluginContainer (../../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:113:13) at Function.normalisePlugin (../../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:146:32) at ../../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:184:30
at Array.map (<anonymous>)
at Function.normalisePlugins (../../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:158:20)
at OptionManager.mergeOptions (../../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:234:36)
at OptionManager.init (../../../node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (../../../node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (../../../node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (../../../node_modules/babel-core/lib/transformation/pipeline.js:46:16)
This is what my package.json looks like:
{
"name": "nanny-now",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "jest --verbose --runInBand",
"test:watch": "npm run test -- --watch",
"build": "babel src -d lib -s true",
"start": "node lib/index.js",
"start:watch": "nodemon src/index.js --exec babel-node"
},
"jest": {
"testEnvironment": "node"
},
"repository": {
"type": "git",
"url": ""
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#babel/cli": "^7.1.5",
"#babel/core": "^7.2.0",
"#babel/node": "^7.0.0",
"#babel/plugin-proposal-class-properties": "^7.1.0",
"#babel/plugin-proposal-decorators": "^7.1.6",
"#babel/plugin-syntax-dynamic-import": "^7.0.0",
"#babel/preset-env": "^7.1.6",
"babel-eslint": "^10.0.1",
"babel-jest": "^23.6.0",
"chance": "^1.0.18",
"eslint": "^5.9.0",
"eslint-plugin-babel": "^5.3.0",
"jest": "^23.6.0",
"nodemon": "^1.18.7",
"supertest": "^3.3.0"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"dotenv": "^6.2.0",
"express": "^4.16.4",
"jsonwebtoken": "^8.4.0",
"mongoose": "^5.3.14",
"morgan": "^1.9.1",
"regenerator-runtime": "^0.13.1"
}
}
Here is my .babelrc file:
{
"presets": [
"#babel/preset-env"
],
"plugins": [
[
"#babel/plugin-proposal-decorators",
{
"decoratorsBeforeExport": true
}
],
"#babel/plugin-proposal-class-properties"
]
}
As George Artemiou says, this error occurs because you are using Babel 7 in your project, while jest still uses Babel 6.
I had the same issue, and I solved it by installing babel-core#^7.0.0-bridge.0
See also:
https://github.com/babel/babel-bridge
The problem is with jest dependencies. I had the same issue and resolved it by adding the step below to my package.json file
"scripts": {
...
"postinstall": "rimraf node_modules/jest-runtime/node_modules/babel-core node_modules/jest-config/node_modules/babel-core",
...
}
Hope this helps..

Expo react native peer dependency

I am getting issue since expo sdk 28 upgrade.
Warning: 'react-native' peer dependency missing. Run npm ls in /Users/macbook/Desktop/eventlinn to see full warning.
Warning: 'react' peer dependency missing. Run npm ls in /Users/macbook/Desktop/eventlinn to see full warning.
My package.json like this
"dependencies": {
"#expo/samples": "2.1.1",
"axios": "^0.18.0",
"expo": "^28.0.0",
"impagination": "^1.0.0-alpha.3",
"moment": "^2.22.2",
"native-base": "^2.7.1",
"pod": "^0.9.0",
"react": "^16.3.1",
"react-native": "https://github.com/expo/react-native/archive/sdk-28.0.0.tar.gz",
"react-native-camera": "^1.1.4",
"react-native-datepicker": "^1.7.2",
"react-native-dismissable-numeric-keyboard": "^0.1.0",
"react-native-elements": "^0.19.1",
"react-native-fcm": "^6.2.3",
"react-native-firebase": "^4.2.0",
"react-native-flexi-radio-button": "^0.2.2",
"react-native-google-places": "^2.5.2",
"react-native-keyboard-aware-scroll-view": "^0.6.0",
"react-native-modal-datetime-picker": "^5.1.0",
"react-native-modal-dropdown": "^0.6.2",
"react-native-modal-picker": "0.0.16",
"react-native-modal-selector": "0.0.27",
"react-native-select-input-ios": "^1.2.0",
"react-navigation": "~2.3.1",
"react-timer-mixin": "^0.13.3",
"util": "^0.10.3",
"watchman": "^1.0.0",
"yarn": "^1.7.0"
}
First update your dependencies version from below dependencies then add your additional required dependencies in that from yours:
{
"name": "nativebasedemo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest",
"clean": "rm -rf $TMPDIR/react-* && watchman watch-del-all && npm cache clean --force",
"newclear": "rm -rf $TMPDIR/react-* && watchman watch-del-all && rm -rf ios/build && rm -rf node_modules/ && npm cache clean --force && npm i",
"test:watch": "jest --watch",
"lint": "eslint ./App",
"lintdiff": "git diff --name-only --cached --relative | grep '\\.js$' | xargs standard | snazzy",
"fixcode": "eslint --fix ./App",
"git-hook": "npm run lint -s && npm run test -s",
"rm-node": "rm -rf node_modules && npm install"
},
"dependencies": {
"lodash": "^4.17.10",
"native-base": "^2.4.4",
"prop-types": "^15.6.1",
"react": "16.3.2",
"react-native": "^0.55",
"react-native-easy-grid": "^0.2.0",
"react-navigation": "2.2.5"
},
"devDependencies": {
"babel-core": "6.26.0",
"babel-eslint": "^8.2.5",
"babel-jest": "22.4.3",
"babel-plugin-ignite-ignore-reactotron": "^0.3.0",
"babel-preset-env": "^1.6.1",
"babel-preset-react-native": "^3.0.2",
"eslint": "^4.19.1",
"eslint-config-airbnb": "^16.1.0",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.7.0",
"jest": "22.4.3"
},
"jest": {
"testMatch": [
"<rootDir>/Tests/**/*.js",
"**/?(*.)(spec|test).js?(x)"
],
"testPathIgnorePatterns": [
"/node_modules/",
"<rootDir>/Tests/Setup.js"
],
"moduleNameMapper": {
"^.+\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "identity-obj-proxy"
},
"setupFiles": [
"<rootDir>/Tests/Setup"
],
"preset": "react-native"
}
}
I had a similar issue, with both react and react-native.
Ended up locking down native-base version to 2.6.1.
This way, native-base doesn't ask for higher versions, which sdk-28.0.0.tar.gz doesn't have.

Unexpected use of reserved word 'import React-native

My bable.src file code is here
{
"presets": ["es2015"]
}
Package.json file code is here
{
"name": "Zoylo",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json",
"test": "jest"
},
"dependencies": {
"#ptomasroos/react-native-multi-slider": "0.0.11",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"jwt-node-decoder": "0.0.4",
"npm": "^5.3.0",
"prop-types": "^15.6.1",
"react": "^16.2.0",
"react-dom": "^16.3.2",
"react-native": "^0.52.0",
},
"devDependencies": {
"babel-eslint": "^8.0.3",
"babel-jest": "20.0.3",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-preset-env": "^1.6.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-react-native": "^4.0.0",
"babel-preset-stage-2": "^6.24.1",
"jest": "20.0.4",
"react-test-renderer": "16.0.0-alpha.12"
},
}
I think its a bable issue. Its working fine just 1 day ago and after npm install i am facing this issue.
I got the answer. I had some problem in .babelrc file now here is my new .babelrc file
{ "env": { "test": { "presets": [ "env", "react", "es2015", "stage-2" ], "plugins": [ "transform-export-extensions" ], "only": [ "./**/*.js", "node_modules/jest-runtime" ] } }, "presets": [ "react-native" ] }
and need to run this command also.
watchman watch-del-all && rm -rf node_modules/ && npm cache clean --force && npm install && npm start -- --reset-cache