Eslint - eslint-config-airbnb not find - javascript

I'm getting some errors module eslint-config-airbnb not found, when run command eslint **/*.jsx.
package.json file
{
"name": "reactapp",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"precommit": "npm test",
"start": "webpack-dev-server --hot"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"husky": "^0.14.3",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"webpack": "^3.5.5",
"webpack-dev-server": "^2.7.1"
},
"devDependencies": {
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0"
}
}
eslintrc file
{
"extends": "airbnb"
}

Check to see if your eslint has been installed / installed correctly.
Also reinstall your node_modules folder as well, if eslint has been configured.
Since eslint isn't in your devDependencies, I assumed you've got it set up globally?
I've copied your package.json set up, but tested it with a local eslint and it's working for me.
"scripts":
{
"precommit": "npm test",
"start": "webpack-dev-server --hot",
"lint": "eslint **/*.jsx --fix"
}
...
"devDependencies":
{
"eslint": "^4.5.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-jsx-a11y": "^5.1.1",
"eslint-plugin-react": "^7.3.0"
}

npm install -D rimraf prettier babel-eslint eslint-plugin-react eslint-plugin-jsx-a11y eslint-plugin-import eslint-config-prettier eslint-config-airbnb eslint-plugin-react-hooks
npm run build
Try running this, worked for me.

Related

Nuxt PWA with directory errors

After a while without playing with Nuxtjs today I decided to start a project on it with PWA support, everything installed and the template created almost as usual, just missing a relatively useless directory - assets -, but when I go to `yarn dev` several of these errors appear:
ERROR ENOENT: no such file or directory, open '/home/runner/anisite/node_modules/.cache/pwa/icon/iphonexsmax_1242x2688.png'
then at the end it appears:
Killed
error Command failed with exit code 137
My package.json
{
"name": "anisite",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"lint:js": "eslint --ext \".js,.vue\" --ignore-path .gitignore .",
"lint": "yarn lint:js",
"test": "jest"
},
"dependencies": {
"#nuxtjs/axios": "^5.13.6",
"#nuxtjs/pwa": "^3.3.5",
"core-js": "^3.15.1",
"nuxt": "^2.15.7"
},
"devDependencies": {
"#babel/eslint-parser": "^7.14.7",
"#nuxtjs/eslint-config": "^6.0.1",
"#nuxtjs/eslint-module": "^3.0.2",
"#nuxtjs/tailwindcss": "^4.2.0",
"#vue/test-utils": "^1.2.1",
"babel-core": "7.0.0-bridge.0",
"babel-jest": "^27.0.5",
"eslint": "^7.29.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-nuxt": "^2.0.0",
"eslint-plugin-vue": "^7.12.1",
"jest": "^27.0.5",
"postcss": "^8.3.5",
"prettier": "^2.3.2",
"vue-jest": "^3.0.4"
}
}
Edits:
I already deleted the cache directories
I already reinstalled everything

Couldn't find preset "#babel/env" - reactjs

I want to build my application but I got this error message:
ERROR in ./src/index.js
Module build failed: Error: Couldn't find preset "#babel/env" relative to directory "/Users/mohammadmehdi/Documents/Work/sevenapp"
at /Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19
at Array.map (<anonymous>)
at OptionManager.resolvePresets (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20)
at OptionManager.mergePresets (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10)
at OptionManager.mergeOptions (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14)
at OptionManager.init (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12)
at File.initOptions (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/index.js:212:65)
at new File (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/file/index.js:135:24)
at Pipeline.transform (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transpile (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-loader/lib/index.js:50:20)
at Object.module.exports (/Users/mohammadmehdi/Documents/Work/sevenapp/node_modules/babel-loader/lib/index.js:173:20)
my package.json:
{
"name": "sevenapp",
"version": "0.1.0",
"private": true,
"dependencies": {
"axios": "^0.18.0",
"babel-preset-react": "^6.24.1",
"bootstrap": "^4.0.0",
"html-webpack-plugin": "^3.2.0",
"jquery": "^3.3.1",
"rc-pagination": "^1.16.4",
"react": "^16.2.0",
"react-countup": "^3.0.3",
"react-dom": "^16.2.0",
"react-paginate": "^5.2.3",
"react-player": "^1.6.4",
"react-popup": "^0.9.3",
"react-redux": "^5.0.7",
"react-router": "^4.2.0",
"react-router-dom": "^4.2.2",
"react-scripts": "1.1.1",
"redux": "^4.0.0"
},
"scripts": {
"start": "webpack-dev-server --mode development --open",
"build": "webpack --mode production",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"description": ":D",
"main": "index.js",
"devDependencies": {
"#babel/preset-env": "^7.0.0-beta.51",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.4",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-3": "^6.24.1",
"css-loader": "^0.28.11",
"jshint": "^2.9.5",
"jshint-loader": "^0.8.4",
"style-loader": "^0.21.0",
"url-loader": "^1.0.1",
"webpack": "^4.6.0",
"webpack-cli": "^2.0.15"
},
"author": "MM",
"license": "ISC"
}
my .babelrc file:
{
"presets": [
"#babel/env",
"#babel/preset-react",
[
"#babel/preset-stage-3",
{
"decoratorsLegacy": true
}
]
]
}
what is my wrong?
my OS is macOS highSierra version 10.13.3 node js version 10 react version 16.2
nodejs version 10
webpack version 4
npm version 6.0.1
but couldn't find preset "#babel/env"
How to solve this problem???
This is the problem with your presets definition in your .babelrc. The correct preset name is preset-env, not env.
Update your .babelrc from #babel/env to #babel/preset-env will solve the problem.

Preact.js - How to start a auto re run server like React.js does

I would like to use a development server just like React does with npm start. But, with Preact when I use the same command it opens a static server and I have to restart it manually each time when I want to see some change in my project.
My package.json:
{
"name": "yagoazedias-site",
"version": "0.0.0",
"description": "Ready-to-go Preact starter project powered by webpack.",
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --inline --hot --progress",
"start": "serve build -s -c 1",
"prestart": "npm run build",
"build": "cross-env NODE_ENV=production webpack --progress",
"prebuild": "mkdirp build && ncp src/assets build/assets",
"test": "npm run -s lint && jest --coverage",
"test:watch": "npm run -s test -- --watch",
"lint": "eslint src test"
},
"keywords": [
"preact",
"boilerplate",
"webpack"
],
"license": "MIT",
"author": "Jason Miller <jason#developit.ca>",
"jest": {
"setupFiles": [
"./test/setup.js"
],
"testURL": "http://localhost:8080",
"moduleFileExtensions": [
"js",
"jsx"
],
"moduleDirectories": [
"node_modules"
],
"moduleNameMapper": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
"\\.(css|less)$": "identity-obj-proxy",
"^react$": "preact-compat",
"^react-dom$": "preact-compat"
},
"collectCoverageFrom": [
"src/**/*.{js,jsx}"
]
},
"devDependencies": {
"autoprefixer": "^7.0.1",
"babel": "^6.5.2",
"babel-core": "^6.24.0",
"babel-eslint": "^7.2.2",
"babel-jest": "^20.0.0",
"babel-loader": "^7.0.0",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-stage-0": "^6.5.0",
"babel-register": "^6.24.0",
"babel-runtime": "^6.11.6",
"chai": "^4.0.2",
"copy-webpack-plugin": "^4.0.1",
"core-js": "^2.4.1",
"cross-env": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^4.1.0",
"eslint-plugin-jest": "^20.0.0",
"eslint-plugin-react": "^7.0.0",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^0.11.1",
"html-webpack-plugin": "^2.28.0",
"identity-obj-proxy": "^3.0.0",
"jest": "^20.0.0",
"json-loader": "^0.5.4",
"less": "^2.7.1",
"less-loader": "^4.0.3",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"offline-plugin": "^4.7.0",
"postcss-loader": "^2.0.3",
"preact-jsx-chai": "^2.2.1",
"raw-loader": "^0.5.1",
"regenerator-runtime": "^0.10.3",
"replace-bundle-webpack-plugin": "^1.0.0",
"script-ext-html-webpack-plugin": "^1.3.4",
"sinon": "^2.1.0",
"sinon-chai": "^2.9.0",
"source-map-loader": "^0.2.1",
"style-loader": "^0.18.1",
"url-loader": "^0.6.1",
"webpack": "^3.0.0",
"webpack-dev-server": "^2.4.4"
},
"dependencies": {
"preact": "^8.1.0",
"preact-compat": "^3.15.0",
"preact-render-to-string": "^3.6.0",
"preact-router": "^2.5.1",
"promise-polyfill": "^6.0.2",
"proptypes": "^1.0.0",
"serve": "^6.0.0"
},
"main": "webpack.config.babel.js",
"directories": {
"test": "test"
}
}
Relevant links:
https://preactjs.com/
https://github.com/developit/preact
Use the dev script instead?
$ npm run dev
Your start script is doing serve build -s -c 1. React CRA's start script will boot up a webpack dev server which is what your dev script is doing.
npm start is short for npm run start. npm run <command> is just a small proxy that looks up the different commands you have listed in package.json.
Read more about npm scripts here.

npm does not install the package.json dependencies

I've been struggling with a weird bug. I'm trying to install project dependencies on my server with a simple npm i but it does not create any node_modules folder.
Also, I've tried all of the probable solutions like npm init in order to make a new package.json file or I deleted package-lock.json file.
However, the package.json file works smoothly on my local environment.
here is my package.json file:
{
"name": "expressmvc",
"version": "1.0.0",
"description": "Webpack and Express backend boilerplate Edit",
"main": "app.babel.js",
"dependencies": {
"axios": "^0.16.2",
"babel-runtime": "^6.23.0",
"bcrypt": "^1.0.3",
"bluebird": "^3.5.0",
"body-parser": "~1.16.0",
"connect-mongo": "^1.3.2",
"cookie-parser": "~1.4.3",
"cron": "^1.3.0",
"debug": "~2.6.0",
"express": "~4.14.1",
"express-session": "^1.15.5",
"gmail-api-sync": "^1.2.8",
"gmail-sender-oauth": "^1.0.5",
"googleapis": "^21.3.0",
"moment": "^2.18.1",
"mongoose": "^4.9.2",
"morgan": "~1.7.0",
"node-cron": "^1.2.1",
"nodemon": "^1.11.0",
"passport": "^0.4.0",
"passport-google-oauth20": "^1.0.0",
"pug": "~2.0.0-beta10",
"serve-favicon": "~2.3.2"
},
"devDependencies": {
"babel-cli": "^6.24.0",
"babel-core": "^6.26.0",
"babel-eslint": "^8.0.0",
"babel-loader": "^7.1.2",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.6.0",
"babel-preset-es2015": "^6.24.0",
"babel-preset-es2016": "^6.22.0",
"babel-preset-stage-2": "^6.24.1",
"babel-register": "^6.26.0",
"mocha": "^3.5.0",
"prettier-eslint": "^8.1.0",
"webpack": "^3.5.5"
},
"scripts": {
"test": "mocha 'app/**/*.test.js' --compilers js:babel-core/register --recursive",
"start": "NODE_ENV=production node ./build/backend.js",
"run-dev": "DEBUG=express:* nodemon ./app.js --exec babel-node",
"build": "rm -f -r build && NODE_ENV=production webpack --config ./webpack.config.js --progress --profile --colors"
},
"repository": {
"type": "git",
"url": "git+https://github.com/PedramMarandi/express-js-boilerplate.git"
},
"keywords": [
"expressjs",
"boilerplate",
"es6",
"javascript",
"MVC"
],
"author": "Pedram Marandi",
"license": "ISC",
"bugs": {
"url": "https://github.com/PedramMarandi/express-js-boilerplate/issues"
},
"homepage": "https://github.com/PedramMarandi/express-js-boilerplate#readme"
}
NPM version 3.10.10
Node version 6.10.3
This issue is mainly due to permission problem on Linux machine . You can try after changing the write permission of your deployment folder using this command
sudo chmod -R 777 /home/nodejsAppFloder

babel-runtime missing interop-require-default

No idea how to go about fixing this error. Did some google searching and followed what people recommended. Even removed node_modules and reinstalled but nothing works
I am getting this error:
Error: Cannot find module 'babel-runtime/helpers/interop-require-default' (While processing preset: "/Users/bli1/Development/node_modules/babel-preset-es2015/index.js")
package.json:
{
"name": "braddy",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "npm-run-all --parallel testApp:watch testServer:watch open:src lint:watch",
"open:src": "babel server/server.js",
"testApp": "mocha --reporter nyan tests/testSetup.js \"app/**/*.test.js\"",
"testApp:watch": "npm run testApp -- --watch",
"testServer": "mocha --reporter progress tests/testSetup.js \"server/**/*.test.js\"",
"testServer:watch": "npm run testServer -- --watch",
"lint": "node_modules/.bin/esw webpack.config.* app server tests",
"lint:watch": "npm run lint -- --watch"
},
"author": "",
"license": "ISC",
"dependencies": {
"babel": "^6.5.2",
"babel-cli": "^6.18.0",
"babel-core": "^6.18.2",
"babel-loader": "^6.2.8",
"babel-register": "^6.18.0",
"babel-runtime": "^6.18.0",
"express": "^4.14.0",
"jquery": "^3.1.1",
"react": "^15.4.1",
"react-dom": "^15.4.1",
"react-router": "^3.0.0",
"redux": "^3.6.0",
"redux-thunk": "^2.1.0"
},
"devDependencies": {
"babel-preset-react": "^6.16.0",
"babel-runtime": "^6.18.0",
"cheerio": "^0.22.0",
"eslint": "^3.11.1",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-react": "^6.8.0",
"eslint-watch": "^2.1.14",
"eventsource-polyfill": "^0.9.6",
"extract-text-webpack-plugin": "^1.0.1",
"jsdom": "^9.8.3",
"loglevel": "^1.4.1",
"mocha": "^3.2.0",
"npm-run-all": "^3.1.2",
"open": "0.0.5",
"react-hot-loader": "^1.3.1",
"webpack": "^1.13.3",
"webpack-dev-middleware": "^1.8.4",
"webpack-dev-server": "^1.16.2",
"webpack-hot-middleware": "^2.13.2"
}
}
The plugin babel-preset-es2015 is missing in your package.json, and not installed when you do npm install. Add it, and install again.

Categories

Resources