eslint-plugin-import
eslint-plugin-import copied to clipboard
Can't run tests after fresh clone and npm i
Apologies if I missed something obvious somewhere in the documentation of the repository.
I cloned the repository, ran npm i
and followed with npm run test
but I get the following output:
➜ eslint-plugin-import git:(main) npm run test
> [email protected] pretest
> linklocal
tests/files/order-redirect
resolvers/webpack
tests/files/symlinked-module
tests/files/order-redirect-scoped
utils
resolvers/node
Linked 6 dependencies
> [email protected] test
> npm run tests-only
> [email protected] tests-only
> npm run mocha tests/src
> [email protected] mocha
> cross-env BABEL_ENV=test nyc mocha tests/src
/Users/mussin.benarbia/code/eslint-plugin-import/tests/src/cli.js:4
import path from 'path';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1153:20)
at Module._compile (node:internal/modules/cjs/loader:1205:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Module.require (node:internal/modules/cjs/loader:1115:19)
at require (node:internal/modules/helpers:130:18)
at /Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.9.0
=============================== Coverage summary ===============================
Statements : 0% ( 0/5927 )
Branches : 0% ( 0/3876 )
Functions : 0% ( 0/818 )
Lines : 0% ( 0/3641 )
================================================================================
You need to run the dep time travel script with an eslint and node version specified; I’m not at a computer atm but you can follow the github actions workflow.
Is this mentioned anywhere in the docs? If not I'm thinking I could add it. At the very least it's not an obvious thought for someone trying to contribute for the first time.
Once you've got it working, please do PR in something to https://github.com/import-js/eslint-plugin-import/blob/main/CONTRIBUTING.md, thanks!
I tried following this GA run but still get the same error.
Here is my full output
eslint-plugin-import git:(main) pwd
/Users/mussin.benarbia/code/eslint-plugin-import
eslint-plugin-import git:(main) node --version
v20.10.0
eslint-plugin-import git:(main) npm --version
10.2.3
eslint-plugin-import git:(main) echo $NPM_CONFIG_LEGACY_PEER_DEPS
true
eslint-plugin-import git:(main) echo $ESLINT_VERSION
8
eslint-plugin-import git:(main) echo $TRAVIS_NODE_VERSION
20
eslint-plugin-import git:(main) npm install
npm WARN deprecated [email protected]: This package is deprecated. Use Array.isArray.
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated [email protected]: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated [email protected]: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated [email protected]: Please use the native JSON object instead of JSON 3
npm WARN deprecated [email protected]: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated [email protected]: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated [email protected]: Deprecated: Use @typescript-eslint/parser instead
npm WARN deprecated [email protected]: This package is unmaintained. Use @sinonjs/formatio instead
npm WARN deprecated [email protected]: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
npm WARN deprecated [email protected]: This package has been deprecated in favour of @sinonjs/samsam
npm WARN deprecated [email protected]: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated [email protected]: no longer maintained
npm WARN deprecated [email protected]: This package was moved to @typescript-eslint/typescript-estree, please install the latest version from there instead
npm WARN deprecated [email protected]: 16.1.1
npm WARN deprecated [email protected]: core-js@<3.23.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. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
> [email protected] prepublish
> not-in-publish || npm run prepublishOnly
added 787 packages, and audited 1120 packages in 48s
112 packages are looking for funding
run `npm fund` for details
42 vulnerabilities (4 low, 12 moderate, 19 high, 7 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
eslint-plugin-import git:(main) npm run copy-metafiles && ./tests/dep-time-travel.sh
> [email protected] copy-metafiles
> node --require babel-register ./scripts/copyMetafiles
LICENSE -> memo-parser/LICENSE
.npmrc -> memo-parser/.npmrc
LICENSE -> resolvers/node/LICENSE
.npmrc -> resolvers/node/.npmrc
LICENSE -> resolvers/webpack/LICENSE
.npmrc -> resolvers/webpack/.npmrc
LICENSE -> utils/LICENSE
.npmrc -> utils/.npmrc
installing 8 in node 20 with TS parser default...
removed 2 packages, changed 2 packages, and audited 1120 packages in 10s
112 packages are looking for funding
run `npm fund` for details
42 vulnerabilities (4 low, 12 moderate, 19 high, 7 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
Installing self
npm WARN using --force Recommended protections disabled.
changed 1 package, and audited 1120 packages in 847ms
112 packages are looking for funding
run `npm fund` for details
42 vulnerabilities (4 low, 12 moderate, 19 high, 7 critical)
To address issues that do not require attention, run:
npm audit fix
To address all issues possible (including breaking changes), run:
npm audit fix --force
Some issues need review, and may require choosing
a different dependency.
Run `npm audit` for details.
Build self
> [email protected] prebuild
> rimraf lib
> [email protected] build
> babel --quiet --out-dir lib src
> [email protected] postbuild
> npm run copy-metafiles
> [email protected] copy-metafiles
> node --require babel-register ./scripts/copyMetafiles
LICENSE -> memo-parser/LICENSE
.npmrc -> memo-parser/.npmrc
LICENSE -> resolvers/node/LICENSE
.npmrc -> resolvers/node/.npmrc
LICENSE -> resolvers/webpack/LICENSE
.npmrc -> resolvers/webpack/.npmrc
LICENSE -> utils/LICENSE
.npmrc -> utils/.npmrc
eslint-plugin-import git:(main) npm run pretest
> [email protected] pretest
> linklocal
tests/files/order-redirect
resolvers/webpack
tests/files/symlinked-module
tests/files/order-redirect-scoped
utils
resolvers/node
Linked 6 dependencies
eslint-plugin-import git:(main) npm run tests-only
> [email protected] tests-only
> npm run mocha tests/src
> [email protected] mocha
> cross-env BABEL_ENV=test nyc mocha tests/src
/Users/mussin.benarbia/code/eslint-plugin-import/tests/src/cli.js:4
import path from 'path';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:77:18)
at wrapSafe (node:internal/modules/cjs/loader:1288:20)
at Module._compile (node:internal/modules/cjs/loader:1340:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at /Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/lib/mocha.js:231:27
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/lib/mocha.js:228:14)
at Mocha.run (/Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/lib/mocha.js:514:10)
at Object.<anonymous> (/Users/mussin.benarbia/code/eslint-plugin-import/node_modules/mocha/bin/_mocha:480:18)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
at Module.load (node:internal/modules/cjs/loader:1207:32)
at Module._load (node:internal/modules/cjs/loader:1023:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49
Node.js v20.10.0
=============================== Coverage summary ===============================
Statements : 0% ( 0/5927 )
Branches : 0% ( 0/3876 )
Functions : 0% ( 0/818 )
Lines : 0% ( 0/3641 )
================================================================================
Do you perhaps have a package.json
in an enclosing directory that sets type
? What does npm config list
print out (please redact any credentials)?
Thank you for your help investigating this. Searching for "type": "
doesn't find anything other than "type": "git"
under the repository field in a few package.json files. I'm also on the latest commit, no local changes.
Here is my output, double-checked that it doesn't contain any sensitive data.
Output
eslint-plugin-import git:(main) pwd
/Users/mussin.benarbia/code/eslint-plugin-import
eslint-plugin-import git:(main) git status
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean
eslint-plugin-import git:(main) git --no-pager log -1
commit 7a21f7e10f18c04473faadca94928af6b8e28009 (HEAD -> main, origin/main, origin/HEAD)
Author: Jordan Harband <[email protected]>
Date: Fri Dec 29 09:18:33 2023 -0800
[meta] add missing changelog entry from #2942
eslint-plugin-import git:(main) git --no-pager grep -r "\"type\": \"" .
memo-parser/package.json: "type": "git",
package.json: "type": "git",
resolvers/node/package.json: "type": "git",
resolvers/webpack/package.json: "type": "git",
utils/package.json: "type": "git",
eslint-plugin-import git:(main) npm config list -l
; "default" config from default values
_auth = (protected)
access = null
all = false
allow-same-version = false
also = null
audit = true
audit-level = null
auth-type = "web"
before = null
bin-links = true
browser = null
ca = null
cache = "/Users/mussin.benarbia/.npm"
cache-max = null
cache-min = 0
cafile = null
call = ""
cert = null
cidr = null
color = true
commit-hooks = true
cpu = null
depth = null
description = true
dev = false
diff = []
diff-dst-prefix = "b/"
diff-ignore-all-space = false
diff-name-only = false
diff-no-prefix = false
diff-src-prefix = "a/"
diff-text = false
diff-unified = 3
dry-run = false
editor = "vi"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
fetch-timeout = 300000
force = false
foreground-scripts = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
globalconfig = "/Users/mussin.benarbia/Library/Application Support/fnm/node-versions/v20.10.0/installation/etc/npmrc"
heading = "npm"
https-proxy = null
if-present = false
ignore-scripts = false
include = []
include-staged = false
include-workspace-root = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/Users/mussin.benarbia/.npm-init.js"
init-version = "1.0.0"
init.author.email = ""
init.author.name = ""
init.author.url = ""
init.license = "ISC"
init.module = "/Users/mussin.benarbia/.npm-init.js"
init.version = "1.0.0"
; install-links = false ; overridden by project
install-strategy = "hoisted"
json = false
key = null
legacy-bundling = false
; legacy-peer-deps = false ; overridden by env
link = false
local-address = null
location = "user"
lockfile-version = null
loglevel = "notice"
logs-dir = null
logs-max = 10
; long = false ; overridden by cli
maxsockets = 15
message = "%s"
node-options = null
noproxy = [""]
npm-version = "10.2.3"
offline = false
omit = []
omit-lockfile-registry-resolved = false
only = null
optional = null
os = null
otp = null
pack-destination = "."
package = []
; package-lock = true ; overridden by project
package-lock-only = false
parseable = false
prefer-dedupe = false
prefer-offline = false
prefer-online = false
prefix = "/Users/mussin.benarbia/Library/Application Support/fnm/node-versions/v20.10.0/installation"
preid = ""
production = null
progress = true
provenance = false
provenance-file = null
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
replace-registry-host = "npmjs"
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-peer = false
save-prefix = "^"
save-prod = false
sbom-format = null
sbom-type = "library"
scope = ""
script-shell = null
searchexclude = ""
searchlimit = 20
searchopts = ""
searchstaleness = 900
shell = "/bin/zsh"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
strict-peer-deps = false
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
umask = 0
unicode = true
update-notifier = true
usage = false
user-agent = "npm/{npm-version} node/{node-version} {platform} {arch} workspaces/{workspaces} {ci}"
userconfig = "/Users/mussin.benarbia/.npmrc"
version = false
versions = false
viewer = "man"
which = null
workspace = []
workspaces = null
workspaces-update = true
yes = null
; "project" config from /Users/mussin.benarbia/code/eslint-plugin-import/.npmrc
install-links = false
package-lock = false
; "env" config from environment
legacy-peer-deps = true
; "cli" config from command line options
long = true
eslint-plugin-import git:(main)
@ljharb Sorry to disturb but do you have any other possible suggestions? I wonder if all other (new) contributors are able to run everything just fine 🤔 I actually wanted to look into another issue, but without fixing this I'm unable to do anything at all
I’m still trying to figure it out; sorry for the delay.
@ljharb Thank you for your time! Please let me know if there is anything else I can do to provide more information on this, I'd be more than happy to help
@mussinbenarbia were you able to figure this out?
Same exact error for me. Did a fresh fork, npm i
and npm run test
.
And got the error.
Environment: OS: Macos Node: v20.10.0 Npm: 10.2.3
I think this might be related to the fact that the lockfile is not versioned. It's actually a bad pratice. It should be versioned.
Is there anything i can try to do?
There is no lockfile at all to have a version, and no, packages should not have lockfiles.
@AndreaPontrandolfo do you have type module set in ~/.package.json
or something?
do you have type module set in ~/.package.json or something?
No (just run cat ~/.package.json
and got "No such file or directory", just to make sure)
@AndreaPontrandolfo what node version are you using? can you confirm you used npm to install?
what node version are you using?
As said earlier Node v20.10.0.
And yes, i normally use pnpm
so i'm not too familiar with npm
, but i used npm
here.
ah thanks. i could suggest 20.13 but i don't think it'll make a difference.
I'm very confused; I can't reproduce it even on a fresh install.