naugtur / npm-audit-resolver

Apache License 2.0
121 stars 28 forks source link

Cannot read property 'reduce' of undefined #38

Closed mfrieling closed 2 years ago

mfrieling commented 3 years ago

I just installed npm-audit-resolver as described and executed resolve-audit and immediately got this error message:

>>>> npm audit --json
>>>> exit: 0
TypeError: Cannot read property 'reduce' of undefined
    at Object.askForResolutions (/home/linuxbrew/.linuxbrew/lib/node_modules/npm-audit-resolver/src/resolve/auditResolver.js:13:50)
    at /home/linuxbrew/.linuxbrew/lib/node_modules/npm-audit-resolver/resolve.js:17:30
    at processTicksAndRejections (node:internal/process/task_queues:94:5)

My intention of using this tool is to fix all dependencies listed by npm audit except one, which triggers a deprecation warning about several dozen times. As this deprecation is located in an external (commercial) package which I can't fix I want to keep Sass version < 1.32.0 until the vendor provides a fix.

lenymo commented 3 years ago

I have just noticed a similar thing when I tried to run resolve-audit today on my Mac running Big Sur 11.3.1.

Here's my error:

>>>> npm audit --json 
>>>> exit: 0
TypeError: Cannot read property 'reduce' of undefined
    at Object.askForResolutions (/usr/local/lib/node_modules/npm-audit-resolver/src/resolve/auditResolver.js:13:50)
    at /usr/local/lib/node_modules/npm-audit-resolver/resolve.js:17:30
    at processTicksAndRejections (node:internal/process/task_queues:94:5)

Trying to get around a fairly widespread postcss vuln which has just been identified: https://www.npmjs.com/advisories/1693

lenymo commented 3 years ago

Just wanted to clarify that I encountered the error while running both npm-audit-resolver@2.2.0, npm-audit-resolver@2.2.1 and npm-audit-resolver@2.3.0

mkatanski commented 3 years ago

I'm afraid I have the same issue.

System: MacOS Catalina 10.15.7 Node.js v14.15.0 npm-audit-resolver 2.3.0

error:

>>>> npm audit --json --registry https://registry.npmjs.org
>>>> exit: 0
TypeError: Cannot read property 'reduce' of undefined
    at Object.askForResolutions (/node_modules/npm-audit-resolver/src/resolve/auditResolver.js:13:50)
    at node_modules/npm-audit-resolver/resolve.js:17:30
    at processTicksAndRejections (internal/process/task_queues.js:93:5)

EDIT: I think its related to the newest version of NPM (currently I have 7.12.1)

EDIT 2: I can confirm that installing older npm version solves the problem. In my case I did npm i -g npm@latest-6 which should point to the v6.14.13 according to https://www.npmjs.com/package/npm?activeTab=versions

I hope it will be helpful to someone ;)

naugtur commented 3 years ago

Hi, thanks for reporting. It's a duplicate. https://github.com/naugtur/npm-audit-resolver/issues/34

npm version 7 has introduced a significant breaking change to the audit output and I'm only now figuring it out.

For now, a workaround is to use npm6 or yarn1 audit capabilities or installing npm6 as a dev dependency if that's more suitable.

naugtur commented 2 years ago

closing in favor of #34