Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ryangrahamnc opened this issue Jul 24, 2024 · 9 comments
Open

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

ryangrahamnc opened this issue Jul 24, 2024 · 9 comments

Comments

@ryangrahamnc
Copy link

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:
SBoudrias/Inquirer.js@ec78662
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"
    }
},
@rmarquois
Copy link

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
Copy link

kastov commented Jul 31, 2024

Thanks a lot!

@exact01
Copy link

exact01 commented Jul 31, 2024

thanks

@litzebauer
Copy link

litzebauer commented Aug 16, 2024

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
Copy link

tit commented Aug 17, 2024

Thank you!

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

Work for me

@jesusCamOn
Copy link

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

nnnnusui added a commit to nnnnusui/web-playground that referenced this issue Aug 31, 2024
`[ERROR] String.prototype.split called on null or undefined`
plopjs/plop#445
nvlang added a commit to nvlang/sveltex that referenced this issue Sep 1, 2024
Issue #9 seems to be a consequence of
plopjs/plop#445. As a temporary workaround, as
suggested in that issue's comments, I'm hard-coding the 9.3.5 version of
`inquirer` in `package.json`, which should fix the issue for now. If and
when Plop and/or Inquirer fix the root cause, this temporary fix here
should be reverted and a newer minimum version of `plop` should be
required in the `package.json` file.

Fixes #9.
alimpens added a commit to Amsterdam/design-system-prototypes that referenced this issue Sep 4, 2024
VincentSmedinga pushed a commit to Amsterdam/design-system-prototypes that referenced this issue Sep 5, 2024
* Add new site templates

* Fix opening curly bracket

* Fix templates

* Show docs

* Add workaround for plop issue

plopjs/plop#445
guanghechen added a commit to guanghechen/node-scaffolds that referenced this issue Sep 17, 2024
guanghechen added a commit to guanghechen/node-scaffolds that referenced this issue Sep 17, 2024
@arodik
Copy link

arodik commented Sep 18, 2024

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

@AllanOricil
Copy link

Thank you!

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

Work for me

this worked

@awhitford
Copy link

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants