Eslint SyntaxError: Unexpected token = - npm

I've encountered the following error while using eslint command in my project:
$ eslint ./src/ --max-warnings 69 --ext .js,.jsx,.ts,.tsx
Oops! Something went wrong! :(
ESLint: 7.7.0
.../node_modules/language-tags/lib/Tag.js:17
static ERR_DEPRECATED = 1;
^
SyntaxError: Unexpected token =
at new Script (vm.js:83:7)
at NativeCompileCache._moduleCompile (.../node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
at Module._compile (.../node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (.../node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (.../node_modules/language-tags/lib/index.js:11:11)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I am using the following plugins and configs for eslint:
{
"#typescript-eslint/eslint-plugin": "4.15.2",
"#typescript-eslint/parser": "4.15.2",
"eslint": "7.7.0",
"eslint-config-airbnb": "18.2.1",
"eslint-config-airbnb-typescript": "9.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-dirnames": "1.0.3",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "5.0.3",
"eslint-plugin-unicorn": "18.0.1"
}
I've tried to reproduce the correct package configuration which worked fine before I started switching my project from npm to yarn v1 (this problem happened because of that). But current yarn.lock is about 25000 lines long and it is tough to compare it to package-lock.json.

I solved this problem by myself eventually and want to share the solution.
The problem lied in the eslint-plugin-jsx-a11y#6.4.1 package.
Its dependencies are listed below:
dependencies:
"#babel/runtime" "^7.11.2"
aria-query "^4.2.2"
array-includes "^3.1.1"
ast-types-flow "^0.0.7"
axe-core "^4.0.2"
axobject-query "^2.2.0"
damerau-levenshtein "^1.0.6"
emoji-regex "^9.0.0"
has "^1.0.3"
jsx-ast-utils "^3.1.0"
language-tags "^1.0.5"
As it turns out, yarn v1 resolved the dependency language-tags#^1.0.5 as language-tags#1.0.7 which caused the eslint command to stop working altogether.
language-tags#^1.0.5:
version "1.0.7"
resolved ".../npm/language-tags/-/language-tags-1.0.7.tgz#41cc248730f3f12a452c2e2efe32bc0bbce67967"
integrity ...
dependencies:
language-subtag-registry "^0.3.20"
So the solution is to either change the version of language-tags in your lock file from 1.0.7 to 1.0.5 or provide a yarn resolution where you would specify the desired package version
"resolutions": {
"language-tags": "1.0.5"
}

Related

pod install error on react native project

When I cd ios && pod install, I keep getting this error.
I tried several things like
delete node_modules and yarn install again, yarn cache clean, pod deintegrate, etc., but no luck.
❯ pod install
error Failed to load configuration of your project.
[!] Invalid `Podfile` file: 859: unexpected token at 'Error: ENOENT: no such file or directory, lstat '/Users/user/dev/fondee-rn-webview/ios/node_modules/#bam.tech/react-native-make'
at Object.lstatSync (node:fs:1514:3)
at /Users/user/dev/fondee-rn-webview/node_modules/graceful-fs/polyfills.js:319:16
at Object.<anonymous> (/Users/user/dev/fondee-rn-webview/node_modules/#bam.tech/react-native-make/react-native.config.js:9:13)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at module.exports (/Users/user/dev/fondee-rn-webview/node_modules/cosmiconfig/node_modules/import-fresh/index.js:28:9)
info Run CLI with --verbose flag for more details.
'.
# from /Users/user/dev/fondee-rn-webview/ios/Podfile:24
# -------------------------------------------
# target 'fondee' do
> config = use_native_modules!
#
# -------------------------------------------
How can I successfully install pod?
I did update all the packages (yarn upgrade --latest).
Here is my package.json:
"dependencies": {
"#notifee/react-native": "7.2.0",
"#react-native-async-storage/async-storage": "^1.17.10",
"#react-native-clipboard/clipboard": "^1.8.5",
"#react-native-firebase/app": "^16.4.6",
"#react-native-firebase/messaging": "^16.4.6",
"#types/react": "^18.0.26",
"react": "18.2.0",
"react-native": "0.70.6",
"react-native-device-info": "^10.3.0",
"react-native-permissions": "^3.6.1",
"react-native-progress": "^5.0.0",
"react-native-send-intent": "^1.3.0",
"react-native-splash-screen": "^3.3.0",
"react-native-webview": "^11.15.0"
},
"devDependencies": {
"#babel/core": "^7.12.9",
"#babel/runtime": "^7.12.5",
"#bam.tech/react-native-make": "^3.0.3",
"#react-native-community/eslint-config": "^3.2.0",
"#types/jest": "^29.2.4",
"#types/react-native": "^0.70.7",
"#types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.3.1",
"eslint": "^8.29.0",
"jest": "^29.3.1",
"metro-react-native-babel-preset": "^0.73.4",
"react-test-renderer": "18.2.0",
"typescript": "^4.4.4"
},
"resolutions": {
"#types/react": "^18.0.26"
},
The error is occurring because #bam.tech/react-native-make does not have pod file. Why are you using this package? The package is old and has only 20 weekly downloads.
You can follow this blog to create splash screens.

"expo start --web" suddenly failing with "Body must be a string. Received: undefined"

I have just recently started with React Native and expo.
After completing a test app in the local web/dev server, I have been able to get it to work on an Android phone over a USB connection. But now the previously working web/dev server is failing:
> expo start --web
Starting project at C:\...\testproject
Body must be a string. Received: undefined.
Error: Body must be a string. Received: undefined.
at devAssert (C:\...\testproject\node_modules\graphql\jsutils\devAssert.js:12:11)
at new Source (C:\...\testproject\node_modules\graphql\language\source.js:37:56)
at new Parser (C:\...\testproject\node_modules\graphql\language\parser.js:86:62)
at Object.parse (C:\...\testproject\node_modules\graphql\language\parser.js:30:16)
at Object.<anonymous> (C:\...\testproject\node_modules\graphql-tools\src\stitching\introspectSchema.ts:7:48)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! testproject#1.0.0 dev:web: `expo start --web`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the testproject#1.0.0 dev:web script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The expo build:web command is still working though. It exports a fully functional web app to the web-build directory.
Dependencies:
"dependencies": {
"expo": "^45.0.6",
"expo-gl": "^11.3.0",
"expo-keep-awake": "^10.1.1",
"expo-navigation-bar": "^1.2.0",
"expo-splash-screen": "~0.15.1",
"expo-status-bar": "^1.3.0",
"expo-three": "^6.1.0",
"expo-web-browser": "~10.2.1",
"react": "17.0.2",
"react-dom": "^18.2.0",
"react-native": "0.68.2",
"react-native-safe-area-context": "^4.3.1",
"react-native-screens": "^3.13.1",
"react-native-web": "^0.18.1",
"three": "^0.141.0"
},
"devDependencies": {
"#babel/core": "^7.18.5",
"#expo/webpack-config": "^0.16.24",
"#types/babel__core": "^7.1.19",
"#types/babel__template": "^7.4.1",
"#types/react": "~18.0.14",
"#types/react-native": "^0.69.0",
"#types/three": "^0.141.0",
"#typescript-eslint/eslint-plugin": "^5.29.0",
"#typescript-eslint/parser": "^5.29.0",
"eas-cli": "^0.54.1",
"eslint": "^8.18.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.30.1",
"eslint-plugin-react-hooks": "^4.6.0",
"expo-cli": "^5.4.11",
"expo-dev-client": "^1.0.0",
"husky": "^8.0.0",
"prettier": "^2.7.1",
"typescript": "~4.7.4"
}
Problem solved.
expo start -c -w (with -c to clear the cache) revealed the problem.
Apparently a dependency update had gone wrong; React is at 17, and React-DOM and the types are at 18. Upgrading all to 18 resulted in new/different errors, so I have now downgraded all to 17 and the dev server is working again.
for me, I had expo-cli as a dependency, as soon as I removed this, the message went away
I had expo-cli(v5.4.7) as a dev dependency. Upgrading to v6.0.6 made it work for me

Gitlab Pipeline Fails-Error: We don't support cucumber version 6

hi i have an angularJs project. We prepared E2E tests for the project. I want to integrate these tests into gitlab pipeline. The log I got from Pipeline is as follows;
npm run test
> protractor-typescript-cucumber#4.0.0 test
> protractor typeScript/config/config.js
[07:45:54] I/launcher - Running 1 instances of WebDriver
[07:45:54] I/local - Starting selenium standalone server...
[07:45:55] I/local - Selenium standalone server started at http://10.235.216.81:51027/wd/hub
[07:45:58] E/launcher - Error: Error: We don't support cucumber version 6
at Object.<anonymous> (/builds/i3uGB66D/0/cloudnesiltech/delivery/bdd/bdd-delivery-web/node_modules/protractor-cucumber-framework/lib/resultsCapturer.js:31:11)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:94:18)
at Function.loadCustomFormatter (/builds/i3uGB66D/0/cloudnesiltech/delivery/bdd/bdd-delivery-web/node_modules/cucumber/lib/formatter/builder.js:110:29)
at Function.getConstructorByType (/builds/i3uGB66D/0/cloudnesiltech/delivery/bdd/bdd-delivery-web/node_modules/cucumber/lib/formatter/builder.js:77:33)
at Function.build (/builds/i3uGB66D/0/cloudnesiltech/delivery/bdd/bdd-delivery-web/node_modules/cucumber/lib/formatter/builder.js:38:40)
at /builds/i3uGB66D/0/cloudnesiltech/delivery/bdd/bdd-delivery-web/node_modules/cucumber/lib/cli/index.js:104:31
[07:45:58] E/launcher - Process exited with error code 100
My package.json file;
"devDependencies": {
"#cucumber/cucumber": "^7.2.1",
"#types/cucumber": "^4.0.4",
"#types/node": "^10.7.1",
"#types/selenium-webdriver": "^3.0.10",
"all-contributors-cli": "^5.4.0",
"chai": "^4.1.2",
"chai-as-promised": "^7.1.1",
"cucumber-html-reporter": "^4.0.3",
"mkdirp": "^0.5.1",
"protractor": "^5.4.0",
"protractor-cucumber-framework": "^6.1.1",
"rimraf": "^2.6.2",
"ts-node": "^7.0.1",
"typescript": "^3.0.1"
},
"repository": "https://github.com/igniteram/protractor-cucumber-typescript",
"dependencies": {
"cucumber": "^6.0.5",
"webdriver-manager": "12.1.8"
}

Module is extraneous npm

I've checked that the connect-privkey-to-provider module is in the dependencies. However, it keeps saying Module 'connect-privkey-to-provider' is extraneous npm and cannot find module 'connect-privkey-to-provider'.
What's wrong with my code?
PS C:\Users\1Sun\addition-game-starter> truffle deploy --network
klaytn
Error: Cannot find module 'connect-privkey-to-provider'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\1Sun\addition-game-starter\truffle.js:2:29)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Function.Config.load (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:254:1)
at Function.Config.detect (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:243:1)
at Object.run (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\commands\migrate.js:35:1)
at Command.run (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\command.js:101:1)
at Object. (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\cli.js:22:1)
at webpack_require (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap
0791995565e53f633c90:19:1)
at C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap
0791995565e53f633c90:65:1
at Object. (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:71:10)
at Module._compile (internal/modules/cjs/loader.js:701:30)
package.json
{
"name": "klay-dapp-boilerplate",
"version": "0.0.1",
"description": "boilerplate for klaytn-based app",
"main": "truffle.js",
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server"
},
"dependencies": {
"caver-js": "^0.0.2-m",
"connect-privkey-to-provider": "^0.0.3",
"spin.js": "^4.0.0"
},
"devDependencies": {
"copy-webpack-plugin": "^4.6.0",
"eslint": "^4.19.1",
"webpack": "^4.7.0",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.4"
},
"eslintConfig": {
"env": {
"browser": true,
"node": true
}
}
}
truffle.js
// truffle.js config for klaytn.
const PrivateKeyConnector = require('connect-privkey-to-provider')
const NETWORK_ID = '1001'
const GASLIMIT = '20000000'
const URL ='https://api.baobab.klaytn.net:8651'
const PRIVATE_KEY = '0x80ea7e298ba2cbf484e6c0c0703ccf2ea94be7f8a1a097fc013042b4888a2e80'
module.exports = {
networks: {
klaytn: {
provider: new PrivateKeyConnector(PRIVATE_KEY, URL),
network_id: NETWORK_ID,
gas: GASLIMIT,
gasPrice: null,
}
}
}
Error
Your code works fine in my environment. Try to do these:
Remove node_modules
Remove package-lock.json
Update truffle package npm update -g truffle
Reinstall, using command npm i
After that just change solidity version in contracts folder
pragma solidity ^0.5.0;
In my case for changing some dependencies, I was deleting node_modules, but I had to erase package-lock.json too.
I closed all windows, deleted node_modules folder and package-lock.json and reinstalled it all again with npm install.

Error: Cannot find module 'less' with pnpm

Im trying to use pnpm but get this error on the buildmachine:
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:339:15)
at Function.require.resolve (internal/module.js:23:19)
at resolve_engine_path (C:\BuildAgent\_work\Web\App\node_modules\.registry.npmjs.org\accord\0.26.4\node_modules\accord\lib\index.js:65:18) at Object.exports.load (C:\BuildAgent\_work\Web\App\node_modules\.registry.npmjs.org\accord\0.26.4\node_modules\accord\lib\index.js:25:19) at Object.<anonymous> (C:\BuildAgent\_work\Web\App\node_modules\.registry.npmjs.org\gulp-less\3.3.0\node_modules\gulp-less\index.js:9:29) at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
##[error]Running build failed.
##[error]Error:
##[error]System.Exception: Failed to run gulp build-release
Im trying to reslove this error but cant figure out how to get pnpm to install the module. Accorging to this issue this should be resloved already:
https://github.com/pnpm/pnpm/issues/118
Some of the package.json:
"devDependencies": {
"aurelia-bundler": "^0.3.2",
"aurelia-tools": "^0.1.0",
"babel-eslint": "^4.1.6",
"del": "^1.1.0",
"eslint": "^1.10.3",
"eslint-plugin-aurelia": "^0.3.0",
"gulp": "^3.8.10",
"gulp-babel": "^5.1.0",
"gulp-bump": "^0.1.11",
"gulp-changed": "^1.1.0",
"gulp-concat": "^2.5.2",
"gulp-cssmin": "^0.1.7",
"gulp-eslint": "^1.1.1",
"gulp-jshint": "^1.9.0",
"gulp-less": "^3.0.1",
"gulp-plumber": "^0.6.6",
"gulp-shell": "^0.4.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-uglify": "^1.1.0",
Anyone had this issue and solved it?
Please let me know if im missing some info out!
You can run npm install less in terminal