Skip to content

Cannot read properties of undefined (reading 'stdin') #4138

Closed

Description

@sk8gear

Details

I was trying to test Vuejs 3 by creating a new Vuejs 3 project, then try to run it by using "npm run serve". This is what I got:

$ npm run build

> vue-test-003@0.1.0 build
> vue-cli-service build

npm ERR! Cannot read properties of undefined (reading 'stdin')

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\devcomp\AppData\Local\npm-cache\_logs\2023-03-31T05_12_09_205Z-debug-0.log

And here's the content of .log file:

0 verbose cli C:\Program Files\nodejs\node.exe C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
1 info using npm@9.6.2
2 info using node@v18.15.0
3 timing npm:load:whichnode Completed in 3ms
4 timing config:load:defaults Completed in 3ms
5 timing config:load:file:C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 3ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:D:\testdir\vue-test-003\.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:C:\Users\devcomp\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\devcomp\AppData\Roaming\npm\etc\npmrc Completed in 2ms
14 timing config:load:global Completed in 2ms
15 timing config:load:setEnvs Completed in 2ms
16 timing config:load Completed in 19ms
17 timing npm:load:configload Completed in 19ms
18 timing npm:load:mkdirpcache Completed in 1ms
19 timing npm:load:mkdirplogs Completed in 0ms
20 verbose title npm run build
21 verbose argv "run" "build"
22 timing npm:load:setTitle Completed in 2ms
23 timing config:load:flatten Completed in 6ms
24 timing npm:load:display Completed in 8ms
25 verbose logfile logs-max:10 dir:C:\Users\devcomp\AppData\Local\npm-cache\_logs\2023-03-31T05_12_09_205Z-
26 verbose logfile C:\Users\devcomp\AppData\Local\npm-cache\_logs\2023-03-31T05_12_09_205Z-debug-0.log
27 timing npm:load:logFile Completed in 13ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 47ms
31 silly logfile start cleaning logs, removing 10 files
32 timing command:run Completed in 19ms
33 verbose stack TypeError: Cannot read properties of undefined (reading 'stdin')
33 verbose stack     at promiseSpawn (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:60:18)
33 verbose stack     at spawnWithShell (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:123:10)
33 verbose stack     at promiseSpawn (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\lib\index.js:12:12)
33 verbose stack     at runScriptPkg (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script-pkg.js:79:13)
33 verbose stack     at runScript (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\run-script\lib\run-script.js:9:16)
33 verbose stack     at RunScript.run (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\lib\commands\run-script.js:129:13)
33 verbose stack     at async module.exports (C:\Users\devcomp\AppData\Roaming\npm\node_modules\npm\lib\cli.js:134:5)
34 verbose cwd D:\testdir\vue-test-003
35 verbose Windows_NT 10.0.19045
36 verbose node v18.15.0
37 verbose npm  v9.6.2
38 error Cannot read properties of undefined (reading 'stdin')
39 verbose exit 1
40 timing npm Completed in 105ms
41 verbose code 1
42 error A complete log of this run can be found in:
42 error     C:\Users\devcomp\AppData\Local\npm-cache\_logs\2023-03-31T05_12_09_205Z-debug-0.log

(https://github.com/nodejs/help/files/11118438/2023-03-31T05_12_09_205Z-debug-0.log)

So far, I've tried reinstalling nodejs and using the latest version (Node.js 19.8.1) and have had no luck. I also tried to remove all npm and npm-cache in AppData/Local and AppData/Roaming, reinstall it, and tried to run "npm run serve" again and still return exact same error as above.

Node.js version

Node.js version v18.15.0

Example code

No response

Operating system

Currently using Windows 10

Scope

Issue occured when I tried to run "npm run serve" on Vuejs project.

Module and version

Not applicable.

Activity

  1. preveen-stack commented on Apr 21, 2023

    @preveen-stack
    Contributor

    please share relevant lines of code

  2. sk8gear commented on May 3, 2023

    @sk8gear
    Author

    I'd love to share the code that caused the problem. But, the error occurred every time I tried to run "npm run build". I tried to create a new Nextjs project too, and it also gave me the same error. I wonder if there's any setting that I need to check and modify to make "npm run" command work.

  3. chathura226 commented on Jun 11, 2023

    @chathura226

    I'd love to share the code that caused the problem. But, the error occurred every time I tried to run "npm run build". I tried to create a new Nextjs project too, and it also gave me the same error. I wonder if there's any setting that I need to check and modify to make "npm run" command work.

    did you find any solution?

  4. protogenyx commented on Dec 22, 2023

    @protogenyx

    In my case, it was due to the console type, specifically git bash. Changing it to powershell solved this issue for me.

  5. sk8gear commented on Jan 22, 2024

    @sk8gear
    Author

    In my case, it was due to the console type, specifically git bash. Changing it to powershell solved this issue for me.

    I tried this and now I can use npm again in my system. I'm wondering why I can't use npm in git bash? Anyway, thank you for your help.

  6. avivkeller commented on Jul 1, 2024

    @avivkeller
    Member

    Is this issue still occuring? If not, feel free to self-close.

  7. sk8gear commented on Aug 12, 2024

    @sk8gear
    Author

    For now, I can't say that the issue has been solved if I used git bash. But, changing to powershell helped.

  8. Panossa commented on Jan 22, 2026

    @Panossa

    Hi, sorry for necro posting, but I have the same error just now, apparently.
    I'm on Win 11 Pro with GIT v2.52.0.windows.1 and Node v20.11.0 (because of an older Angular version).

    Here's my setup, minimized:

    package.json
    echo.js
    echo.sh
    

    echo.js is just a .js file with console.log("test"); inside.
    echo.sh is just a bash script with a node echo.js call inside.

    package.json has scripts like these:

    {
      "echo": "echo test",
      "necho": "node echo.js"
    }

    The following are what I tried to do and their results:

    Envionment Command Result
    Git Bash npm run echo stdin error
    Git Bash npm run necho stdin error
    Git Bash winpty npm.cmd run echo works
    Git Bash . echo.sh works
    CMD npm run echo works
    CMD npm run necho works
    CMD winpty npm.cmd run echo works
    CMD . echo.sh works

    The stdin error changes between versions, too:

    • Node v20.11.0: stdin error
    • Node v20.20.0: no error, but also no echo output (generally broken but doesn't give errors)
    • Node v21.7.3: stdin error
    • Node v22.19.0: no error, but also no echo output (same as 20.20)

    Edit:
    Node version 24.13.0 and the newest (v25) works! Isn't usable for me because of Angular but at least there's that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions