npm ERR! Cannot read properties of undefined (reading 'stdin') - vue.js

I have an error when running vue.js 3 with vite
I added nodejs into Variable Environments before
I have tried these things but not working
using npm cache clear & npm cache clear --force but still error and receive npm WARN using --force Recommended protections disabled.
deleted node_modules folder and package.lock.json and run npm install
re-clone my repo on Github
re-installed Nodejs, VSCode, vite.js, update to latest npm
Debug log:
0 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli 'run',
0 verbose cli 'dev'
0 verbose cli ]
1 info using npm#8.1.2
2 info using node#v17.1.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
6 timing config:load:builtin Completed in 2ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\Admin\Desktop\xfago-cms-vue\.npmrc Completed in 0ms
10 timing config:load:project Completed in 0ms
11 timing config:load:file:C:\Users\Admin\.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:C:\Users\Admin\AppData\Roaming\npm\etc\npmrc Completed in 1ms
14 timing config:load:global Completed in 1ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 7ms
19 timing npm:load:configload Completed in 7ms
20 timing npm:load:setTitle Completed in 0ms
21 timing npm:load:setupLog Completed in 0ms
22 timing config:load:flatten Completed in 2ms
23 timing npm:load:cleanupLog Completed in 1ms
24 timing npm:load:configScope Completed in 0ms
25 timing npm:load:projectScope Completed in 1ms
26 timing npm:load Completed in 12ms
27 timing command:run-script Completed in 7ms
28 verbose stack TypeError: Cannot read properties of undefined (reading 'stdin')
28 verbose stack at promiseSpawnUid (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:70:18)
28 verbose stack at promiseSpawn (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:15:10)
28 verbose stack at runScriptPkg (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\run-script\lib\run-script-pkg.js:54:13)
28 verbose stack at runScript (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\run-script\lib\run-script.js:9:16)
28 verbose stack at RunScript.run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:129:13)
29 verbose cwd C:\Users\Admin\Desktop\xfago-cms-vue
30 verbose Windows_NT 10.0.19043
31 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
32 verbose node v17.1.0
33 verbose npm v8.1.2
34 error Cannot read properties of undefined (reading 'stdin')
35 verbose exit 1```

The solution was to run the command npm init to create a "complete" package.json file.

same issue found to me beacuse i used
npm config --global set x = "Y"
so this is the huge mistake i did for that i need to unintall nodejs
and also delete C:/Users/"username"/Appdata/Roming/ delete npm from here as well,
again install it, it worked for me
i know this is not a solution but issue is according to me have only this solution.

Related

npm ERR! code ENOENT. Does not create a new package.json or install dependencies

I wanted to start a new package.json with npm init -y from the windows cmd and the console throws an error.
I tried to solve it this way and it didn't work.
Remove the npm cache with npm cache clean --force.
Update to the latest version of npm
Install the latest version of LTS node.
Uninstall and install node and it didn't work.
C:\Users\ADMIN\Documents\server>npm init -y
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\ADMIN\Documents\server\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\ADMIN\Documents\server\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\ADMIN\AppData\Local\npm-cache\_logs\2023-01-12T00_47_42_486Z-debug-0.log
The npm cache error log
> 0 verbose cli C:\Program Files\nodejs\node.exe
> C:\Users\ADMIN\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js 1
> info using npm#9.2.0 2 info using node#v18.13.0 3 timing
> npm:load:whichnode Completed in 0ms 4 timing config:load:defaults
> Completed in 2ms 5 timing
> config:load:file:C:\Users\ADMIN\AppData\Roaming\npm\node_modules\npm\npmrc
> Completed in 3ms 6 timing config:load:builtin Completed in 3ms 7
> timing config:load:cli Completed in 2ms 8 timing config:load:env
> Completed in 0ms 9 timing config:load:project Completed in 3ms 10
> timing config:load:file:C:\Users\ADMIN\.npmrc Completed in 1ms 11
> timing config:load:user Completed in 1ms 12 timing
> config:load:file:C:\Users\ADMIN\AppData\Roaming\npm\etc\npmrc
> Completed in 0ms 13 timing config:load:global Completed in 1ms 14
> timing config:load:setEnvs Completed in 1ms 15 timing config:load
> Completed in 14ms 16 timing npm:load:configload Completed in 14ms 17
> timing npm:load:mkdirpcache Completed in 0ms 18 timing
> npm:load:mkdirplogs Completed in 0ms 19 verbose title npm doctor 20
> verbose argv "doctor" 21 timing npm:load:setTitle Completed in 2ms 22
> timing config:load:flatten Completed in 3ms 23 timing npm:load:display
> Completed in 4ms 24 verbose logfile logs-max:10
> dir:C:\Users\ADMIN\AppData\Local\npm-cache\_logs\2023-01-12T00_58_05_674Z-
> 25 verbose logfile
> C:\Users\ADMIN\AppData\Local\npm-cache\_logs\2023-01-12T00_58_05_674Z-debug-0.log
> 26 timing npm:load:logFile Completed in 15ms 27 timing npm:load:timers
> Completed in 0ms 28 timing npm:load:configScope Completed in 0ms 29
> timing npm:load Completed in 37ms 30 silly logfile done cleaning log
> files 31 timing config:load:flatten Completed in 1ms 32 info Running
> checkup 33 http fetch GET 200
> https://registry.npmjs.org/-/ping?write=true 453ms (cache miss) 34
> http fetch GET 200 https://registry.npmjs.org/npm 261ms (cache miss)
> 35 timing command:doctor Completed in 4395ms 36 verbose exit 0 37
> timing npm Completed in 4460ms 38 info ok
I applied the solutions that I mentioned and none of them solved the error. Does anyone know how I could solve it? Since I have not found any method to solve it

How to properly run npm install scripts?

I'm trying to execute a Node.js script after my package is installed. But even testing with a simple echo command fails already.
Because I'm testing with local installation first, I've also tried the prepare script instead of install, but get the same results: no execution.
Suppose I have Package A (PA) that I want to install into Package B (PB).
PA's package.json script part looks like the following (tried install and prepare):
"install": "echo INSTALLED"
Installing it in PB like so:
npm install --save-dev ../package-a
But the echo, that should show something in console, seems to do nothing.
What do I oversee?
Update 1
Here's the verbose output of npm-install:
$ npm install --save-dev --loglevel verbose ../package-a/
npm verb cli [
npm verb cli 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli 'C:\\Users\\User\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli '--save-dev',
npm verb cli '--loglevel',
npm verb cli 'verbose',
npm verb cli '../package-a/'
npm verb cli ]
npm info using npm#8.5.5
npm info using node#v16.14.2
npm timing npm:load:whichnode Completed in 0ms
npm timing config:load:defaults Completed in 5ms
npm timing config:load:file:C:\Users\User\AppData\Roaming\npm\node_modules\npm\npmrc Completed in 2ms
npm timing config:load:builtin Completed in 2ms
npm timing config:load:cli Completed in 2ms
npm timing config:load:env Completed in 1ms
npm timing config:load:file:F:\public\npm\package-b\.npmrc Completed in 0ms
npm timing config:load:project Completed in 2ms
npm timing config:load:file:C:\Users\User\.npmrc Completed in 1ms
npm timing config:load:user Completed in 1ms
npm timing config:load:file:C:\Users\User\AppData\Roaming\npm\etc\npmrc Completed in 1ms
npm timing config:load:global Completed in 1ms
npm timing config:load:validate Completed in 0ms
npm timing config:load:credentials Completed in 1ms
npm timing config:load:setEnvs Completed in 0ms
npm timing config:load Completed in 16ms
npm timing npm:load:configload Completed in 16ms
npm timing npm:load:setTitle Completed in 0ms
npm timing config:load:flatten Completed in 3ms
npm timing npm:load:display Completed in 7ms
npm verb logfile C:\Users\User\AppData\Local\npm-cache\_logs\2022-05-02T13_10_48_164Z-debug-0.log
npm timing npm:load:logFile Completed in 17ms
npm timing npm:load:timers Completed in 1ms
npm timing npm:load:configScope Completed in 0ms
npm timing npm:load Completed in 42ms
npm timing arborist:ctor Completed in 1ms
npm timing idealTree:init Completed in 237ms
npm timing idealTree:userRequests Completed in 26ms
npm verb shrinkwrap failed to load node_modules/.package-lock.json missing from node_modules: ../package-c
npm timing idealTree:#root Completed in 16ms
npm timing idealTree:node_modules/package-a Completed in 0ms
npm timing idealTree:buildDeps Completed in 18ms
npm timing idealTree:fixDepFlags Completed in 3ms
npm timing idealTree Completed in 292ms
npm timing reify:loadTrees Completed in 560ms
npm timing reify:diffTrees Completed in 13ms
npm timing reify:retireShallow Completed in 0ms
npm timing reify:createSparse Completed in 3ms
npm timing reify:loadBundles Completed in 0ms
npm verb reify failed optional dependency F:\public\npm\package-b\node_modules\fsevents
npm timing reifyNode:node_modules/fsevents Completed in 21ms
npm timing reifyNode:node_modules/package-a Completed in 24ms
npm timing reify:unpack Completed in 24ms
npm timing reify:unretire Completed in 0ms
npm timing build:queue Completed in 0ms
npm timing build:deps Completed in 2ms
npm timing build:queue Completed in 1ms
npm timing build:links Completed in 1ms
npm timing build Completed in 4ms
npm timing reify:build Completed in 5ms
npm timing reify:trash Completed in 1ms
npm timing reify:save Completed in 64ms
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 422ms
npm timing auditReport:getReport Completed in 429ms
npm timing auditReport:init Completed in 0ms
npm timing reify:audit Completed in 430ms
npm timing reify Completed in 1015ms
added 1 package, and audited 480 packages in 1s
58 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm timing command:install Completed in 1022ms
npm verb exit 0
npm timing npm Completed in 1383ms
npm info ok
Update 2
I've noticed I can run npm install . inside PA and my NPM script is executed. So the question here is: How do I get scripts executed if package is installed by another one?
Try naming your script postinstall, so the script runs automatically after issuing npm install:
"scripts": {
...
"postinstall": "echo INSTALLED"
}
Ok, I still don't understand why, but my solution to get it up and running is:
If using a local path:
Use prepare instead of install or postinstall
prepare seems to only execute if there is also an install script available in package.json.
install may not be empty. So an echo or such is at least required.
If using local *.tgz package use install instead (maybe just run prepare)
As said, I still don't know why it is working like that, because I always understood that behaviour a bit more different than it seems to be.
So further explanation of someone who knows why it only works like that is highly appreciated.

How can I execute Vue-3-playground on my laptop?

I am very new to the Vue ecosystem, and am trying to learn.
I have downloaded the Vue-3 playground onto my mac by cloning the git repository:
git clone https://github.com/vuesomedev/vue-3-playground.git
on my Macbook pro, OS11.4, Big Sur From the vue-3-playground folder, I execute:
npm install
followed by
npm run serve
This last command produces the error:
npm ERR! missing script: serve
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/erlebach/.npm/_logs/2021-06-21T18_30_41_455Z-debug.log
Here is the end of the log:
0 verbose cli [
0 verbose cli '/Users/erlebach/Documents/global_npm_installs/lib/node_modules/node/bin/node',
0 verbose cli '/usr/local/bin/npm',
0 verbose cli 'run',
0 verbose cli 'serve'
0 verbose cli ]
1 info using npm#7.5.3
2 info using node#v16.3.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
5 timing config:load:builtin Completed in 0ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/erlebach/src/2021/vue-3-playground/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/Users/erlebach/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/Users/erlebach/Documents/global_npm_installs/etc/npmrc Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 7ms
19 verbose npm-session c834a8418ac090c8
20 timing npm:load Completed in 33ms
21 timing command:run-script Completed in 2ms
22 verbose stack Error: missing script: serve
22 verbose stack at runScript (/usr/local/lib/node_modules/npm/lib/run-script.js:54:11)
23 verbose cwd /Users/erlebach/src/2021/vue-3-playground
24 verbose Darwin 20.5.0
25 verbose argv "/Users/erlebach/Documents/global_npm_installs/lib/node_modules/node/bin/node" "/usr/local/bin/npm" "run" "serve"
26 verbose node v16.3.0
27 verbose npm v7.5.3
28 error missing script: serve
29 verbose exit 1
Any insight is greatly appreciated. Thank you.

Command 'npm run dev' failed NuxtJS

I get the following error when I try to run my dev server. I am very new to Vue/Nuxt
0 verbose cli [
0 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-
cli.js',
0 verbose cli 'run',
0 verbose cli 'dev'
0 verbose cli ]
1 info using npm#7.6.3
2 info using node#v15.12.0
3 timing config:load:defaults Completed in 1ms
4 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc
Completed in 2ms
5 timing config:load:builtin Completed in 2ms
6 timing config:load:cli Completed in 1ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:D:\Projects\TCG\IGG\iggbouwkostenkompas\.npmrc
Completed in 0ms
9 timing config:load:project Completed in 0ms
10 timing config:load:file:C:\Users\ghoeksema\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Users\ghoeksema\AppData\Roaming\npm\etc\npmrc
Completed in 1ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 0ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 7ms
19 verbose npm-session 46dffbc867d5c2db
20 timing npm:load Completed in 14ms
21 timing command:run Completed in 694ms
22 verbose stack Error: command failed
22 verbose stack at ChildProcess.<anonymous> (C:\Program
Files\nodejs\node_modules\npm\node_modules\#npmcli\promise-spawn\index.js:64:27)
22 verbose stack at ChildProcess.emit (node:events:369:20)
22 verbose stack at maybeClose (node:internal/child_process:1067:16)
22 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
23 verbose pkgid bouwkosten-index#1.0.0
24 verbose cwd D:\Projects\TCG\IGG\iggbouwkostenkompas
25 verbose Windows_NT 10.0.19041
26 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program
Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "dev"
27 verbose node v15.12.0
28 verbose npm v7.6.3
29 error code 1
30 error path D:\Projects\TCG\IGG\iggbouwkostenkompas
31 error command failed
32 error command C:\Windows\system32\cmd.exe /d /s /c nuxt
33 verbose exit 1
I have no idea how fix it and have done some searches but none of the solutions worked for me. Clearing cache also didn't work
Thanks in advance

run-ios and run-android commands failed

Few days ago all was fine and run smoothly.
Today I can’t try my project iOS and Android.
npx react-native run-ios
npx react-native run-android
both commands failed to compile.
I tried to remove node_modules folder, npm install and cd ios pod install
Cleaned the cache and checked if npm package is up to date.
All with no success.
Any help is appreciated and thank you.
Here is the log I get after the failed run-ios command:
0 verbose cli [
0 verbose cli '/usr/local/bin/node',
0 verbose cli '/usr/local/lib/node_modules/npm/bin/npm-cli.js',
0 verbose cli 'exec',
0 verbose cli '--',
0 verbose cli 'react-native',
0 verbose cli 'run-ios'
0 verbose cli ]
1 info using npm#7.5.2
2 info using node#v14.15.4
3 timing config:load:defaults Completed in 2ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 1ms
5 timing config:load:builtin Completed in 1ms
6 timing config:load:cli Completed in 2ms
7 timing config:load:env Completed in 0ms
8 timing config:load:file:/Users/aitassouabdelkader/Downloads/_clever-programmer/_projects/_react_projects/_mes_projets/socialMedia/.npmrc Completed in 1ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/Users/aitassouabdelkader/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/usr/local/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 9ms
19 verbose npm-session f851aed9bb473f1b
20 timing npm:load Completed in 18ms
21 timing command:exec Completed in 15519ms
22 verbose stack Error: command failed
22 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/#npmcli/promise-spawn/index.js:64:27)
22 verbose stack at ChildProcess.emit (events.js:315:20)
22 verbose stack at maybeClose (internal/child_process.js:1048:16)
22 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
23 verbose pkgid socialMedia#0.0.1
24 verbose cwd /Users/aitassouabdelkader/Downloads/_clever-programmer/_projects/_react_projects/_mes_projets/socialMedia
25 verbose Darwin 20.3.0
26 verbose argv "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/bin/npm-cli.js" "exec" "--" "react-native" "run-ios"
27 verbose node v14.15.4
28 verbose npm v7.5.2
29 error code 1
30 error path /Users/aitassouabdelkader/Downloads/_clever-programmer/_projects/_react_projects/_mes_projets/socialMedia
31 error command failed
32 error command sh -c react-native "run-ios"
33 verbose exit 1