npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.44k stars 3.14k forks source link

[BUG] fails to install packages on my Gatsby website #1989

Closed pedrolamas closed 3 years ago

pedrolamas commented 4 years ago

Current Behavior:

npm i fails on my Gatsby website, but works fine with yarn 1.22.10

Expected Behavior:

To install packages with no errors at all!

Steps To Reproduce:

  1. Clone https://github.com/pedrolamas/pedrolamas.com
  2. Remove yarn.lock file
  3. Try npm i -> this will show failure of type mismatch between a few eslint dependencies, however this works with yarn
  4. Remove "eslint-config-prettier" and "eslint-plugin-prettier" dependencies from package.json
  5. Try npm i -> this fails with "Cannot read property 'matches' of undefined"

Environment:

OS: Windows 10 build 19042.572 Node: 12.19.0 npm: 7.0.7 (7.0.2, 7.0.3, 7.0.5 also had the same issue)

pedrolamas commented 4 years ago

FYI, I have tried this in Ubuntu under WSL 2 and had the same results. image

MichaelDeBoey commented 4 years ago

When building gatsby-remark-embedder against Node 15, I got the same error: https://travis-ci.com/github/MichaelDeBoey/gatsby-remark-embedder/jobs/402578685

I managed to get the same error by first doing a clean install on Node 14 (using npm@6.14.8) on macOS, switching to Node 15 (using npm@7.0.2) and doing another npm install.

jkochis commented 3 years ago

I got the same error when installing gatsby-cli. The source of the error is here: https://github.com/npm/arborist/blob/main/lib/arborist/build-ideal-tree.js#L1284. this only happens on npm 7. It works fine on 6.14.8

pedrolamas commented 3 years ago

I just tested with the latest npm 7.0.5 and this problem is still happening.

I've updated the npm version in the initial post.

Alex0007 commented 3 years ago

This error is happening to me also when i trying to install some dependency, react-scripts for example

npm i react-scripts@latest
npm ERR! Cannot read property 'matches' of undefined

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/Alex/.npm/_logs/2020-10-26T09_21_57_921Z-debug.log
Debug log ``` 32 verbose stack TypeError: Cannot read property 'matches' of undefined 32 verbose stack at Arborist.[canPlaceDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1284:15) 32 verbose stack at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1061:36) 32 verbose stack at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1212:41) 32 verbose stack at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:766:46 32 verbose stack at Array.map () 32 verbose stack at Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:766:8) 32 verbose stack at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:202:7) 32 verbose stack at async Promise.all (index 1) 32 verbose stack at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:5) 32 verbose stack at async install (/usr/local/lib/node_modules/npm/lib/install.js:40:5) 33 verbose cwd /Users/Alex/Development/projects/gridmap-explorer 34 verbose Darwin 20.1.0 35 verbose argv "/usr/local/Cellar/node/15.0.1/bin/node" "/usr/local/bin/npm" "i" "react-scripts@latest" 36 verbose node v15.0.1 37 verbose npm v7.0.3 ```
ar4hc commented 3 years ago

my log of that error:

lots of stuff and then ...

1915 silly placeDep ROOT webpack@4.44.2 OK for: @pmmmwh/react-refresh-webpack-plugin@0.4.2 want: >=4.43.0 <6.0.0
1916 timing idealTree Completed in 8573ms
1917 timing command:install Completed in 8577ms
1918 verbose stack TypeError: Cannot read property 'matches' of undefined
1918 verbose stack     at Arborist.[canPlaceDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1284:15)
1918 verbose stack     at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1061:36)
1918 verbose stack     at Arborist.[placeDep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1212:41)
1918 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:766:46
1918 verbose stack     at Array.map (<anonymous>)
1918 verbose stack     at Arborist.[buildDepStep] (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:766:8)
1918 verbose stack     at async Arborist.buildIdealTree (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:202:7)
1918 verbose stack     at async Promise.all (index 1)
1918 verbose stack     at async Arborist.reify (/usr/local/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:5)
1918 verbose stack     at async install (/usr/local/lib/node_modules/npm/lib/install.js:40:5)
*redacted*
1920 verbose Darwin 19.6.0
1921 verbose argv "/usr/local/Cellar/node/15.0.1/bin/node" "/usr/local/bin/npm" "i"
1922 verbose node v15.0.1
1923 verbose npm  v7.0.3
1924 error Cannot read property 'matches' of undefined
1925 verbose exit 1
pedrolamas commented 3 years ago

Latest 7.0.7 version still show this problem, so I updated the main issue above.

isaacs commented 3 years ago

Fixed in latest npm v7. npm i -g npm@7