plopjs / plop

Consistency Made Simple
http://plopjs.com
MIT License
7.06k stars 277 forks source link

[ERROR] String.prototype.split called on null or undefined #445

Open ryangrahamnc opened 1 month ago

ryangrahamnc commented 1 month ago

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:

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"
    }
},
rmarquois commented 1 month ago

Thanks for your feeedback! It helps me a lot.

In my case I added this in my package.json :

  "resolutions": {
    "inquirer": "9.3.5"
  },
kastov commented 1 month ago

Thanks a lot!

exact01 commented 1 month ago

thanks

litzebauer commented 4 weeks ago

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

tit commented 3 weeks ago

Thank you!

"overrides": {
    "node-plop": {
        "inquirer": "9.3.5"
    }
},

Work for me

jesusCamOn commented 2 weeks ago

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" }