npm ERR! Cannot read properties of undefined (reading 'name') - node.js

I have windows 10 laptop. Node.js version is v.16.15.1 and npm version is 8.13.2. I run 'npm install' in terminal and it gives me erors:
npm ERR! Cannot read properties of undefined (reading 'name')
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\h\AppData\Local\npm-cache\_logs\2022-07-07T08_33_12_931Z-debug-0.log
next i open debug-0.log:
45 verbose stack TypeError: Cannot read properties of undefined (reading 'name')
45 verbose stack at C:\Users\h\AppData\Roaming\npm\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\reify.js:285:30
48 verbose node v16.15.1
49 verbose npm v8.13.2
50 error Cannot read properties of undefined (reading 'name')
51 verbose exit 1
52 timing npm Completed in 213ms
53 verbose unfinished npm timer reify 1657134370529
54 verbose unfinished npm timer reify:loadTrees 1657134370538
55 verbose code 1
56 error A complete log of this run can be found in:
56 error C:\Users\h\AppData\Local\npm-cache\_logs\2022-07-06T19_06_10_353Z-debug-0.log

Related

npm installation errorno -104

I am trying to install a package tree-sitter-cli using the latest npm
❯ npm -v
8.6.0
But keep getting the following error.
63 timing command:i Completed in 885ms
64 verbose stack Error: command failedche/_logs/2022-04-04T12_58_29_622Z-debug-0.log
64 verbose stack at ChildProcess.<anonymous> (~/.local/lib/node_modules/npm/node_
modules/#npmcli/promise-spawn/index.js:64:27)
64 verbose stack at ChildProcess.emit (node:events:527:28)
64 verbose stack at maybeClose (node:internal/child_process:1090:16)
64 verbose stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
65 verbose pkgid tree-sitter-cli#0.20.6
66 verbose cwd /glb/home/innnei
67 verbose Linux 3.10.0-1160.53.1.el7.x86_64
68 verbose node v17.8.0
69 verbose npm v8.6.0
70 error code 1
71 error path ~/.local/lib/node_modules/tree-sitter-cli
72 error command failed
73 error command sh -c node install.js
74 error Downloading https://github.com/tree-sitter/tree-sitter/releases/download/v0.20.6/tree-sitter-linux-x64.gz
75 error node:events:505
75 error throw er; // Unhandled 'error' event
75 error ^
75 error
75 error Error: read ECONNRESET
75 error at TLSWrap.onStreamRead (node:internal/stream_base_commons:217:20)
75 error Emitted 'error' event on ClientRequest instance at:
75 error at TLSSocket.socketErrorListener (node:_http_client:454:9)
75 error at TLSSocket.emit (node:events:527:28)
75 error at emitErrorNT (node:internal/streams/destroy:164:8)
75 error at emitErrorCloseNT (node:internal/streams/destroy:129:3)
75 error at processTicksAndRejections (node:internal/process/task_queues:83:21) {
75 error errno: -104,
75 error code: 'ECONNRESET',
75 error syscall: 'read'
75 error }
75 error
75 error Node.js v17.8.0
76 verbose exit 1
77 timing npm Completed in 1349ms
78 verbose unfinished npm timer reify 1649077110082
79 verbose unfinished npm timer reify:audit 1649077110203
80 verbose unfinished npm timer auditReport:getReport 1649077110203
81 verbose unfinished npm timer reify:build 1649077110257
82 verbose unfinished npm timer build 1649077110257
83 verbose unfinished npm timer build:deps 1649077110257
84 verbose unfinished npm timer build:run:install 1649077110261
85 verbose unfinished npm timer build:run:install:node_modules/tree-sitter-cli 1649077110262
86 verbose code 1
I am behind a corporate proxy (proxy setting is set through shell variables http_proxy & https_proxy ) and npm is working with the proxy settings
❯ npm ping
npm notice PING https://registry.npmjs.org/
npm notice PONG 819ms
This (node & npm) is not really my area of expertise, so I need help in understanding & diagnosing the error.
My npm config is
cache = "~/.local/npmcache"
registry = "https://registry.npmjs.org/"
; "cli" config from command line options
global = true
; node bin location = ~/.local/bin/node
; cwd = $HOME/innnei
; HOME = $HOME/innnei
; Run `npm config ls -l` to show all defaults.
The problem happens when I tried to create a new app using npx create-react-app test-app
after some tries the problem got solved with this command.
npx clear-npx-cache
then after closing the visual studio code editor so that it releases some caches too.
this trick is from this answer
Give it a try.

jasmine version error while running ng new command

I am getting error while running ng new command
below error is fired during the ng new Project-Name-Here
Could not resolve dependency:
error peer jasmine-core#">=3.7.1" from karma-jasmine-html-reporter#1.6.0
silly fetch manifest jasmine-core#>=3.7.1
83 timing idealTree Completed in 8839ms
84 timing command:install Completed in 8849ms
85 verbose stack Error: unable to resolve dependency tree
85 verbose stack at Arborist.[failPeerConflict] (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\build-ideal-tree.js:1141:25)
85 verbose stack at Arborist.[loadPeerSet] (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\build-ideal-tree.js:1118:34)
85 verbose stack at async Arborist.[buildDepStep] (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\build-ideal-tree.js:836:11)
85 verbose stack at async Arborist.buildIdealTree (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\build-ideal-tree.js:209:7)
85 verbose stack at async Promise.all (index 1)
85 verbose stack at async Arborist.reify (C:\Program Files\nodejs\node_modules\npm\node_modules\#npmcli\arborist\lib\arborist\reify.js:130:5)
85 verbose stack at async install (C:\Program Files\nodejs\node_modules\npm\lib\install.js:38:3)
86 verbose cwd C:\Users\PYH0JFQ\source\Hospital\Patient
87 verbose Windows_NT 10.0.19041
88 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--quiet"
89 verbose node v15.11.0
90 verbose npm v7.6.0
91 error code ERESOLVE
92 error ERESOLVE unable to resolve dependency tree
93 error
94 error While resolving: patient#0.0.0
94 error Found: jasmine-core#3.6.0
94 error node_modules/jasmine-core
94 error dev jasmine-core#"~3.6.0" from the root project
94 error
94 error Could not resolve dependency:
94 error peer jasmine-core#">=3.7.1" from karma-jasmine-html-reporter#1.6.0
94 error node_modules/karma-jasmine-html-reporter
94 error dev karma-jasmine-html-reporter#"^1.5.0" from the root project
94 error
94 error Fix the upstream dependency conflict, or retry
94 error this command with --force, or --legacy-peer-deps
94 error to accept an incorrect (and potentially broken) dependency resolution.
I have faced the same issue recently and i got to know this from an online instructor.
you should have phrase the question neatly, anyways
This error is caused by an npm 7 issue. The Angular team recommends to use npm 6 for now.
so downgrade the npm 7 to npm 6 for now
npm install -g npm#6
or
An alternative can be to run ng new with the --skipInstall flag, and then install the dependencies with npm install --legacy-peer-deps.
I found, what I feel is, a better solution.
After running the ng new - go into package.json and simply change
"jasmine-core": "~3.7.0",
to
"jasmine-core": "~3.8.0",
and then run npm install afterwards.

Facing error code ENOENT syscall rename errno -4058 while trying to install node packages

I've been trying to install several node packages that always lead to the npm ERR (images attached below). I was able to install the express package, but not mongoose, mongodb, #angular/cli, during the installation of which I'm facing this error.
The following are my versions of node and npm
Below is the error log that gets saved.
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'E:\\Nodejs\\node.exe',
1 verbose cli 'C:\\Users\\Nanda\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli '#angular/cli'
1 verbose cli ]
2 info using npm#6.14.5
3 info using node#v12.16.3
4 verbose npm-session aa9c7864071a84f9
.
.
.
75 verbose stack Error: ENOENT: no such file or directory, rename 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\tmp\d74359a7' -> 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\1a\94\b0bf25ce70e3a557bd2f6e7ce38f87d6e715bf15d505ea7404b7510dcbb9b86427338b5fbf6ee5543c0aa619fab39ec391345cd432372d4c8a7c6bdb6e09'
76 verbose cwd C:\Users\Nanda
77 verbose Windows_NT 6.1.7601
78 verbose argv "E:\\Nodejs\\node.exe" "C:\\Users\\Nanda\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "#angular/cli"
79 verbose node v12.16.3
80 verbose npm v6.14.5
81 error code ENOENT
82 error syscall rename
83 error path C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\tmp\d74359a7
84 error dest C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\1a\94\b0bf25ce70e3a557bd2f6e7ce38f87d6e715bf15d505ea7404b7510dcbb9b86427338b5fbf6ee5543c0aa619fab39ec391345cd432372d4c8a7c6bdb6e09
85 error errno -4058
86 error enoent ENOENT: no such file or directory, rename 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\tmp\d74359a7' -> 'C:\Users\Nanda\AppData\Roaming\npm-cache\_cacache\content-v2\sha512\1a\94\b0bf25ce70e3a557bd2f6e7ce38f87d6e715bf15d505ea7404b7510dcbb9b86427338b5fbf6ee5543c0aa619fab39ec391345cd432372d4c8a7c6bdb6e09'
87 error enoent This is related to npm not being able to find a file.
88 verbose exit [ -4058, true ]
Note: I'm on a a windows 7, 32-bit system
I had a similar issue and found the following entry on github:
https://github.com/mapbox/node-sqlite3/issues/900
I just deleted the existing node_modules and installed it again with "npm install"

npm outdated error Cannot read property 'length' of undefined

I try running 'npm outdated' from the console in my node project. But I get this error:
npm ERR! Cannot read property 'length' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-03-31T12_26_30_745Z-debug.log
This is the error in the log:
199 verbose stack TypeError: Cannot read property 'length' of undefined
199 verbose stack at dotindex (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:59:32)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:11:21
199 verbose stack at Array.forEach (<anonymous>)
199 verbose stack at forEach (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:73:31)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:10:9
199 verbose stack at Array.reduce (<anonymous>)
199 verbose stack at reduce (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:63:30)
199 verbose stack at module.exports (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\text-table\index.js:9:20)
199 verbose stack at C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:130:16
199 verbose stack at cb (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\slide\lib\async-map.js:47:24)
199 verbose stack at outdated_ (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:221:12)
199 verbose stack at skip (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:343:5)
199 verbose stack at updateDeps (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\lib\outdated.js:446:7)
199 verbose stack at tryCatcher (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
199 verbose stack at Promise.successAdapter [as _fulfillmentHandler0] (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\nodeify.js:23:30)
199 verbose stack at Promise._settlePromise (C:\Users\amita\AppData\Roaming\npm\node_modules\npm\node_modules\bluebird\js\release\promise.js:566:21)
200 verbose cwd C:\Users\amita\Ionic\toratlechima
201 verbose Windows_NT 10.0.17134
202 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\amita\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "outdated"
203 verbose node v10.11.0
204 verbose npm v6.9.0
205 error Cannot read property 'length' of undefined
206 verbose exit [ 1, true ]
This also happens when I try to run it globally.
Anyone encounter this?
Appears to be fixed in the next release, which isn't out yet.
https://github.com/npm/cli/pull/173
You can install the pre-release to fix it.
npm -g i npm#next
Update
NPM 6.9.2 is out
npm install -g npm
There is a bug in the npm, but you can easily fix it:
Go to your npm folder (i.e. /usr/local/lib/node_modules) and find a outdated.js file (i.e. /usr/local/lib/node_modules/npm/lib/outdated.js for Mac or C:\Users\YOUR_USER_NAME\AppData\Roaming\npm\node_modules\npm\lib\outdated.js for Windows)
Find a function makePretty and change
deppath
to
deppath || 'global'
in my case it was line #152
I hope it helps! 🙂
You can also try npm upgrade -g. Worked for me.
Here's how I successfully fixed the error after checking 'global' was in outdated.js file. Without any other requirements like brew etc, (type these commands in the terminal):
sudo npm cache clean -f (force) clear you npm cache
sudo npm install -g n install n (this might take a while)
sudo n stable upgrade to the current stable version
npm upgrade -g upgrade npm
Note that sudo might prompt your password.

Webpack not installing on linux

Recently i changed my environment from windows 10 to backbox linux 4.5.1 but i have tried to install webpack using npm several times . It never installs it gives these errors. Any help ?
verbose tar unpack /home/dove/.npm/webpack/1.12.13/package.tgz
34 silly lockFile 27155615-tar-usr-lib-node-modules-webpack tar:///usr/lib/node_modules/webpack
35 verbose lock tar:///usr/lib/node_modules/webpack /home/dove/.npm/27155615-tar-usr-lib-node-modules-webpack.lock
36 silly lockFile 5c48f9fd--npm-webpack-1-12-13-package-tgz tar:///home/dove/.npm/webpack/1.12.13/package.tgz
37 verbose lock tar:///home/dove/.npm/webpack/1.12.13/package.tgz /home/dove/.npm/5c48f9fd--npm-webpack-1-12-13-package-tgz.lock
38 silly gunzTarPerm modes [ '775', '664' ]
39 error Error: EACCES, mkdir '/usr/lib/node_modules/webpack'
39 error { [Error: EACCES, mkdir '/usr/lib/node_modules/webpack']
39 error errno: 3,
39 error code: 'EACCES',
39 error path: '/usr/lib/node_modules/webpack',
39 error fstream_type: 'Directory',
39 error fstream_path: '/usr/lib/node_modules/webpack',
39 error fstream_class: 'DirWriter',
39 error fstream_stack:
39 error [ '/usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
39 error '/usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53',
39 error 'Object.oncomplete (fs.js:108:15)' ] }
40 error Please try running this command again as root/Administrator.
41 error System Linux 4.2.0-30-generic
42 error command "/usr/bin/node" "/usr/bin/npm" "install" "-g" "webpack#1.12.13"
43 error cwd /home/dove/projects/yulu
44 error node -v v0.10.37
45 error npm -v 1.4.28
46 error path /usr/lib/node_modules/webpack
47 error fstream_path /usr/lib/node_modules/webpack
48 error fstream_type Directory
49 error fstream_class DirWriter
50 error code EACCES
51 error errno 3
52 error stack Error: EACCES, mkdir '/usr/lib/node_modules/webpack'
53 error fstream_stack /usr/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
53 error fstream_stack /usr/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53
53 error fstream_stack Object.oncomplete (fs.js:108:15)
54 verbose exit [ 3, true ]
I think problem is about trying to install npm without sudo privileges since it gave an access error.
"Error: EACCES, mkdir '/usr/lib/node_modules/webpack'"
you should try to run your command with prefix of "sudo"
sudo "your-command"
Also you can try this command too.
npm config set unsafe-perm=true
There is a discussion about this error in github you might want to check it out.
https://github.com/Microsoft/BashOnWindows/issues/14

Resources