help icon indicating copy to clipboard operation
help copied to clipboard

Cannot read properties of undefined (reading 'stdin')

Open sk8gear opened this issue 2 years ago • 6 comments

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

> [email protected] 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 [email protected]
2 info using [email protected]
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.

sk8gear avatar Mar 31 '23 05:03 sk8gear

please share relevant lines of code

preveen-stack avatar Apr 21 '23 08:04 preveen-stack

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.

sk8gear avatar May 03 '23 08:05 sk8gear

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?

chathura226 avatar Jun 11 '23 06:06 chathura226

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

sudo-ditto avatar Dec 22 '23 13:12 sudo-ditto

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.

sk8gear avatar Jan 22 '24 14:01 sk8gear