question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: Cannot read property 'endsWith' of undefined gets thrown in windows when "npm init @vitejs/app" is invoked

See original GitHub issue

Describe the bug

TypeError is thrown on Windows 10 system shell

Reproduction

just run npm init @vitejs/app

System Info

  • vite version: not sure
  • Operating System: Windows 10
  • Node version: 15.11.0
  • Package manager (npm/yarn/pnpm) and version: npm7.6.0

Logs (Optional if provided reproduction)

PS C:\Users\capaj\OneDrive\Dokumenty\GitHub\react-tweet-embed> node -v     
v15.11.0
PS C:\Users\capaj\OneDrive\Dokumenty\GitHub\react-tweet-embed> npm init @vitejs/app
npm notice 
npm notice New patch version of npm available! 7.6.0 -> 7.6.3       
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.6.3
npm notice Run npm install -g npm@7.6.3 to update!
npm notice 
Need to install the following packages:
  @vitejs/create-app
Ok to proceed? (y) y
C:\Users\capaj\AppData\Local\npm-cache\_npx\9c7583f20b80c4d1\node_modules\kolorist\dist\cjs\index.js:25
        if (TERM.endsWith('-256color')) {
                 ^

TypeError: Cannot read property 'endsWith' of undefined
    at Object.<anonymous> (C:\Users\capaj\AppData\Local\npm-cache\_npx\9c7583f20b80c4d1\node_modules\kolorist\dist\cjs\index.js:25:18)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
    at Module.load (node:internal/modules/cjs/loader:972:32)
    at Function.Module._load (node:internal/modules/cjs/loader:813:14)
    at Module.require (node:internal/modules/cjs/loader:996:19)
    at require (node:internal/modules/cjs/helpers:92:18)
    at Object.<anonymous> (C:\Users\capaj\AppData\Local\npm-cache\_npx\9c7583f20b80c4d1\node_modules\@vitejs\create-app\index.js:16:5)
    at Module._compile (node:internal/modules/cjs/loader:1092:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
npm notice
npm notice New patch version of npm available! 7.6.0 -> 7.6.3
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.6.3
npm notice Run npm install -g npm@7.6.3 to update!
npm notice
npm ERR! code 1
npm ERR! path C:\Users\capaj\OneDrive\Dokumenty\GitHub\react-tweet-embed
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c create-app

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\capaj\AppData\Local\npm-cache\_logs\2021-03-17T20_02_37_486Z-debug.log
PS C:\Users\capaj\OneDrive\Dokumenty\GitHub\react-tweet-embed> 

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
marvinhagemeistercommented, Mar 18, 2021

Just booted up my windows machine and I can confirm that it works now, even when downgrading to Node 12.

1reaction
bjarkihallcommented, Mar 17, 2021

kolorist assumes env variable is already defined before essentially doing undefined.endswith.

It had this commited and released 3 hours ago (as 1.3.0 and create-app has dependency on “^1.2.9”): https://github.com/marvinhagemeister/kolorist/commit/ec85371ce6b1695db28d505210b1c3ae00d30c0a#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80

Which causes a runtime error when the module is required. It can be resolved by pinning a stable version of kolorist in @vite/create-app (to prevent kolorist from being able to break vite installs again) and/or by submitting a PR with a fix for 1.3.1 to kolorist.

edit: I just prepared a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Uncaught TypeError: Cannot read property 'endsWith' of ...
After upgrading my Angular 8 application to Angular 9, I get the following error in the browser for one template:
Read more >
npm-init
When set for the npm init command, this may be set to the folder of a workspace which does not yet exist, to...
Read more >
npm err! cannot read properties of undefined (reading 'name')
I am working in laravel project and i want to install laravel breeze. i install node, i make it global, next i run...
Read more >
Set up Node.js on WSL 2 - Windows - Microsoft Learn
Install WSL 2 · Install Windows Terminal (optional) · Install nvm, node.js, and npm · Alternative version managers · Install Visual Studio Code...
Read more >
Cannot read property 'url' of undefined when starting server.js ...
Getting this error when running server.js. Started http server. info - socket.io started node.js:201 throw e; // process.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found