plop icon indicating copy to clipboard operation
plop copied to clipboard

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

Open ryangrahamnc opened this issue 1 year ago • 10 comments
trafficstars

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

ryangrahamnc avatar Jul 24 '24 01:07 ryangrahamnc

Thanks for your feeedback! It helps me a lot.

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

  "resolutions": {
    "inquirer": "9.3.5"
  },

rmarquois avatar Jul 30 '24 08:07 rmarquois

Thanks a lot!

kastov avatar Jul 31 '24 15:07 kastov

thanks

tsforge avatar Jul 31 '24 15:07 tsforge

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

litzebauer avatar Aug 16 '24 18:08 litzebauer

Thank you!

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

Work for me

tit avatar Aug 17 '24 13:08 tit

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

jesusCamOn avatar Aug 27 '24 23:08 jesusCamOn

I rolled back plop in my project to the latest v3 version

arodik avatar Sep 18 '24 16:09 arodik

Thank you!

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

Work for me

this worked

AllanOricil avatar Sep 27 '24 17:09 AllanOricil

In my case, I added this to my package.json:

  "pnpm": {
    "overrides": {
      "inquirer": "9.3.5"
    }

awhitford avatar Oct 17 '24 09:10 awhitford