简体   繁体   中英

ESLint 8.31.0 "Error: Failed to load plugin 'import' declared in '.eslintrc.js » eslint-config-standard': Cannot find module 'array.prototype.flatmap"

Am new to Node and npm in general but I'm pretty sure I've gotten the hang at installing packages locally and whatnot. However, I've been trying to get eslint to work for awhile now and it always fails with the same error message despite trying multiple different test projects. It keeps saying that it cannot find a module 'array.prototype.flatmap' (pic provided below). Node is v18.13.0 and npm is v8.19.3 so I'm up to date. ESLint: ^8.31.0.

My steps are (after using 'npm init' to create a package.json file):

 1. Locally install eslint to project directory using 'npm init @eslint/config' as shown on the site. (I also tried 'npm install -D eslint' AND THEN 'npm init @eslint/config' to configure after installing. 

 2. [Configs](https://i.stack.imgur.com/88f4V.png) I have tried with both standard and airbnb configs. 

 3. Have looked up vids that said to add a script to package.json: "scripts": { "lint": "eslint ./" } and running 'npm run lint'. This results in an error. 

 4. Have tried running npx eslint 'filename.js' .... same error.

This is the error I keep getting: Error msg:

Have tried repeatedly uninstalling packages, reinstalling, different directories and different projects. Even tried other stackoverflow responses to similar issues with different modules, but no avail. The module that always gives me a problem seems to be 'array.prototype.flatmap'.

Not sure where to from this point. Although I do not NEED eslint and might not use it all the time in the future, I don't want to give up trying simply because I'm having installation issues.

I had the same problem. I found this comment and bumped eslint-plugin-import lib.

// package.json

"eslint-plugin-import": "^2.27.2",

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM