TypeError: Cannot read property 'includes' of undefined
adambro opened this issue · comments
It happens for thanks
global install and npx thanks
run:
TypeError: Cannot read property 'includes' of undefined
at isScopedPkg (/home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:205:18)
at /home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:227:21
at Generator.next (<anonymous>)
at step (/home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:2:221)
at _next (/home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:2:409)
at /home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:2:477
at new Promise (<anonymous>)
at /home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:2:97
at _fetchPkg (/home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:243:24)
at fetchPkg (/home/adam/.npm-global/lib/node_modules/thanks/dist/cmd.js:220:24)
Figured out the cause of this. If you have a folder in node_modules/
that has no package.json
, then read-package-tree
returns an empty object instead of a package.json
.
That means the name
property will be undefined, which eventually crashes when isScopedPkg()
is called.
I fixed it at the source: ac8c39f
Released as 1.5.3.