Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run tests after fresh clone and npm i #2946

Open
mussinbenarbia opened this issue Dec 27, 2023 · 9 comments
Open

Can't run tests after fresh clone and npm i #2946

mussinbenarbia opened this issue Dec 27, 2023 · 9 comments

Comments

@mussinbenarbia
Copy link

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

> eslint-plugin-import@2.29.1 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@2.29.1 test
> npm run tests-only


> eslint-plugin-import@2.29.1 tests-only
> npm run mocha tests/src


> eslint-plugin-import@2.29.1 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 )
================================================================================
@ljharb
Copy link
Member

ljharb commented Dec 27, 2023

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.

@mussinbenarbia
Copy link
Author

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.

@ljharb
Copy link
Member

ljharb commented Dec 28, 2023

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!

@mussinbenarbia
Copy link
Author

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 lodash.isarray@4.0.0: This package is deprecated. Use Array.isArray.
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated json3@3.3.2: Please use the native JSON object instead of JSON 3
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated chokidar@1.7.0: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated typescript-eslint-parser@22.0.0: Deprecated: Use @typescript-eslint/parser instead
npm WARN deprecated formatio@1.2.0: This package is unmaintained. Use @sinonjs/formatio instead
npm WARN deprecated fsevents@1.2.13: The v1 package contains DANGEROUS / INSECURE binaries. Upgrade to safe fsevents v2
npm WARN deprecated samsam@1.3.0: This package has been deprecated in favour of @sinonjs/samsam
npm WARN deprecated babel-eslint@8.2.6: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates.
npm WARN deprecated mkdirp@0.5.1: 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 text-encoding@0.6.4: no longer maintained
npm WARN deprecated typescript-estree@18.0.0: This package was moved to @typescript-eslint/typescript-estree, please install the latest version from there instead
npm WARN deprecated sinon@2.4.1: 16.1.1
npm WARN deprecated core-js@2.6.12: 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.

> eslint-plugin-import@2.29.1 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

> eslint-plugin-import@2.29.1 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

> eslint-plugin-import@2.29.1 prebuild
> rimraf lib


> eslint-plugin-import@2.29.1 build
> babel --quiet --out-dir lib src


> eslint-plugin-import@2.29.1 postbuild
> npm run copy-metafiles


> eslint-plugin-import@2.29.1 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

> eslint-plugin-import@2.29.1 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

> eslint-plugin-import@2.29.1 tests-only
> npm run mocha tests/src


> eslint-plugin-import@2.29.1 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 )
================================================================================

@ljharb
Copy link
Member

ljharb commented Dec 29, 2023

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)?

@mussinbenarbia
Copy link
Author

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 <ljharb@gmail.com>
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)

@mussinbenarbia
Copy link
Author

@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

@ljharb
Copy link
Member

ljharb commented Jan 20, 2024

I’m still trying to figure it out; sorry for the delay.

@mussinbenarbia
Copy link
Author

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants