Initializing a new project cdk init app --language typescript
fails on macOS 10.15.7 using node 15.0.1 and npm 7.0.3 with error "Cannot read property 'matches' of undefined".
Running node 15.0.1 and npm 7.0.3 on macOS 10.15.7
npm i -g aws-cdk
cd empty-folder
cdk init app --language typescript
Project initialised without errors
Output error "Cannot read property 'matches' of undefined" in console, and the following in debug log
291 verbose stack TypeError: Cannot read property 'matches' of undefined
291 verbose stack at Arborist.[canPlaceDep] (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1284:15)
291 verbose stack at Arborist.[placeDep] (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1061:36)
291 verbose stack at Arborist.[placeDep] (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:1212:41)
291 verbose stack at /Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:766:46
291 verbose stack at Array.map (<anonymous>)
291 verbose stack at Arborist.[buildDepStep] (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:766:8)
291 verbose stack at async Arborist.buildIdealTree (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js:202:7)
291 verbose stack at async Promise.all (index 1)
291 verbose stack at async Arborist.reify (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/reify.js:121:5)
291 verbose stack at async install (/Users/julianminde/.nvm/versions/node/v15.0.1/lib/node_modules/npm/lib/install.js:40:5)
292 verbose cwd /Users/julianminde/aws/hello-cdk
293 verbose Darwin 19.6.0
294 verbose argv "/Users/julianminde/.nvm/versions/node/v15.0.1/bin/node" "/Users/julianminde/.nvm/versions/node/v15.0.1/bin/npm" "install"
295 verbose node v15.0.1
296 verbose npm v7.0.3
297 error Cannot read property 'matches' of undefined
298 verbose exit 1
I still fear this being a problem with my environment, however I have tried installing node both from brew and using nvm with the same results, and when I use nvm with node version 14.15.0 it seems to work fine.
This is :bug: Bug Report
I ran into the same issue. After npm install -g npm@latest
I could no longer reproduce. Perhaps you want to give it a try.
This is an npm 7.x issue. npm@latest is still on 6.x
Hi @mindejulian, it looks like this is an issue with npm like @pgollucci mentioned. I'm seeing a few bug reports on the npm repo:
Hopefully this issue gets resolved soon. In the meantime, I would use 6.x versions as mentioned above.
I will close this issue since it's not actionable from the CDK side.
Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.
Most helpful comment
I ran into the same issue. After
npm install -g npm@latest
I could no longer reproduce. Perhaps you want to give it a try.