plop
plop copied to clipboard
[ERROR] String.prototype.split called on null or undefined
On a fresh install (when using a tool I made using plop), I'm getting the above error when an action is about to run. I was able to mess with things to get a stacktrace:
TypeError: String.prototype.split called on null or undefined
at split (<anonymous>)
at travel (file:///Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/inquirer/lib/ui/prompt.js:20:10)
at Object.get (file:///Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/inquirer/lib/ui/prompt.js:27:20)
at PromptUI.filterIfRunnable (file:///Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/inquirer/lib/ui/prompt.js:159:9)
at doInnerSub (/Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/rxjs/src/internal/operators/mergeInternals.ts:71:15)
at outerNext (/Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/rxjs/src/internal/operators/mergeInternals.ts:53:58)
at OperatorSubscriber.OperatorSubscriber._this._next (/Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:70:13)
at OperatorSubscriber.Subscriber.next (/Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/rxjs/src/internal/Subscriber.ts:75:12)
at <anonymous> (/Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/rxjs/src/internal/operators/mergeInternals.ts:85:24)
at OperatorSubscriber.OperatorSubscriber._this._next (/Users/ryan/.npm/_npx/08e24d347c8d5920/node_modules/rxjs/src/internal/operators/OperatorSubscriber.ts:70:13)
It looks like its because this inquire.js v9 commit removed the default of '' for the path:
https://github.com/SBoudrias/Inquirer.js/commit/ec786623d5094eee357b912cfaab56b4ddd66f05
I dont know if that was on purpose. I also haven't checked into the full trace to see which function plop is calling.
I figure there's a few possible options to get this working:
- Bug the inquire.js dev to fix a problem in a version that he considers to be legacy. dunno how that would go, but the commit seems to violate semver, so maybe he'll agree its a mistake.
- Pass in a blank string if we think we'll pass null/undefined. Idk where the call is though, so maybe plop doesnt have the ability to influence the call
- Update to the v10 release of inquire.js. IDK if theres compatibility issues though, or if this will even fix the issue
- Hardcode the old inquire.js version in the package.json (
"inquirer": "9.3.5")
In the meantime, I've been able to bypass the problem by adding an override into my own tool's package.json:
"overrides": {
"node-plop": {
"inquirer": "9.3.5"
}
},
Thanks for your feeedback! It helps me a lot.
In my case I added this in my package.json :
"resolutions": {
"inquirer": "9.3.5"
},
Thanks a lot!
thanks
I created a generator that is executed through npx. It doesn't seem like either "overrides" or "resolutions" is respected by npx so I'm still getting the error String.prototype.split called on null or undefined
Thank you!
"overrides": {
"node-plop": {
"inquirer": "9.3.5"
}
},
Work for me
I created a generator that is executed through npx. It doesn't seem like either "overrides" or "resolutions" is respected by npx so I'm still getting the error
String.prototype.split called on null or undefined
I got the same problem. In this case I solved it adding inquirer 9.3.5 as peer dependency.
"peerDependencies": { "inquirer": "9.3.5" }
I rolled back plop in my project to the latest v3 version
Thank you!
"overrides": { "node-plop": { "inquirer": "9.3.5" } },Work for me
this worked
In my case, I added this to my package.json:
"pnpm": {
"overrides": {
"inquirer": "9.3.5"
}