Cli: [BUG] fails to install packages on my Gatsby website

Created on 19 Oct 2020  路  8Comments  路  Source: npm/cli

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:

  • Clone https://github.com/pedrolamas/pedrolamas.com
  • Remove yarn.lock file
  • Try npm i _-> this will show failure of type mismatch between a few eslint dependencies, however this works with yarn_
  • Remove "eslint-config-prettier" and "eslint-plugin-prettier" dependencies from package.json
  • 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)

    Bug Needs Triage Release 7.x

    Most helpful comment

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

    All 8 comments

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

    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 [email protected]) on macOS, switching to Node 15 (using [email protected]) and doing another npm install.

    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

    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.

    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 (<anonymous>)
    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
    

    my log of that error:

    lots of stuff and then ...

    1915 silly placeDep ROOT [email protected] OK for: @pmmmwh/[email protected] 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
    

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

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

    Was this page helpful?
    0 / 5 - 0 ratings