cli
cli copied to clipboard
[BUG] npm ERR! ENOTEMPTY: directory not empty, rename '/usr/local/lib/node_modules/tls-test' -> '/usr/local/lib/node_modules/.tls-test-ow7IxLcQ'
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
installation of https://tls-test.npmjs.com/tls-test-1.0.0.tgz fails
i have tried manually rename '/usr/local/lib/node_modules/tls-test' -> '/usr/local/lib/node_modules/.tls-test-ow7IxLcQ' clearitg 'usr/local/lib/node_modules/.tls-test-ow7IxLcQ' clearing cache downgrade and upgrading npm
when i was trying to solve this problem myself sometimes it throws 'error handler never called error'
Expected Behavior
install https://tls-test.npmjs.com/tls-test-1.0.0.tgz and show success message
Steps To Reproduce
-
In this environment Termux 0.118.0 PWD=/root/node/tutorial LS_OPTIONS=--color=auto HOME=/root LANG=C.UTF-8 TERM=xterm-256color DISPLAY=:1 SHLVL=1 XDG_DATA_DIRS=/root/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:/usr/share:/var/lib/snapd/desktop PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/root/buildAPKs/bin/ _=/usr/bin/printenv OLDPWD=/root/node
-
With this config...
-
Run 'npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz'
-
See error npm ERR! code ENOTEMPTY npm ERR! syscall rename npm ERR! path /usr/local/lib/node_modules/tls-test npm ERR! dest /usr/local/lib/node_modules/.tls-test-ow7IxLcQ npm ERR! errno -39 npm ERR! ENOTEMPTY: directory not empty, rename '/usr/local/lib/node_modules/tls-test' -> '/usr/local/lib/node_modules/.tls-test-ow7IxLcQ' npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2022-11-08T16_36_52_883Z-debug-0.log
Environment
- npm: 8.19.3
- Node.js: 18.12.0
- OS Name: Debian GNU/Linux 10 (buster)
- System Model Name: Realme C25s
- npm config:
; "user" config from /root/.npmrc
registry = "http://registry.npmjs.org/" strict-ssl = false
; node bin location = /usr/local/bin/node
; node version = v18.12.0 ; npm local prefix = /root ; npm version = 8.19.3 ; cwd = /root/node/tutorial
; HOME = /root ; Run `npm config ls -l` to show all defaults.
I get the Same Problem. It's alway tell me syscall rename error
, when npm install
. npm cache clean --force
no useless. So I have to delete the folder,any run npm install
again.
My shell:
>npm init gatsby
>Enter
>Enter
>Javascript
>No
>No
>Enter
npm ERR! code ENOENT
npm ERR! syscall rename
npm ERR! path /root/.npm/_cacache/tmp/f078226a
npm ERR! dest /root/.npm/_cacache/content-v2/sha512/61/dd/d4112e665824aa47ea8d4fddd2dd4a18524a8067d94b83c6bb83dae29ac5a66062bc7154e8038fec17746bb21772577b0018c5d5526a4c60ec3e74ba4ebb
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, rename '/root/.npm/_cacache/tmp/f078226a' -> '/root/.npm/_cacache/content-v2/sha512/61/dd/d4112e665824aa47ea8d4fddd2dd4a18524a8067d94b83c6bb83dae29ac5a66062bc7154e8038fec17746bb21772577b0018c5d5526a4c60ec3e74ba4ebb'
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! /root/.npm/_logs/2023-03-02T08_56_28_578Z-debug-0.log
Command failed with exit code 254: npm install --loglevel error --color always --legacy-peer-deps --no-audit
npm ERR! code 1
npm ERR! path /root/run
npm ERR! command failed
npm ERR! command sh -c -- create-gatsby
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-03-02T08_55_59_014Z-debug-0.log
[root@localhost run]# rm -rf /root/.npm/_cacache/content-v2/sha512/61/dd/d4112e665824aa47ea8d4fddd2dd4a18524a8067d94b83c6bb83dae29ac5a66062bc7154e8038fec17746bb21772577b0018c5d5526a4c60ec3e74ba4ebb
>rm -rf /root/.npm/_cacache/content-v2/sha512/61/dd/d4112e665824aa47ea8d4fddd2dd4a18524a8067d94b83c6bb83dae29ac5a66062bc7154e8038fec17746bb21772577b0018c5d5526a4c60ec3e74ba4ebb
[root@localhost my-gatsby-site]# npm install
npm WARN ERESOLVE overriding peer dependency
npm WARN While resolving: [email protected]
npm WARN Found: [email protected]
npm WARN node_modules/react
npm WARN react@"^18.2.0" from the root project
npm WARN 6 more (@gatsbyjs/reach-router, gatsby, gatsby-link, ...)
npm WARN
npm WARN Could not resolve dependency:
npm WARN peer react@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
npm WARN node_modules/react-server-dom-webpack
npm WARN react-server-dom-webpack@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
npm WARN node_modules/gatsby
npm WARN
npm WARN Conflicting peer dependency: [email protected]
npm WARN node_modules/react
npm WARN peer react@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
npm WARN node_modules/react-server-dom-webpack
npm WARN react-server-dom-webpack@"0.0.0-experimental-c8b778b7f-20220825" from [email protected]
npm WARN node_modules/gatsby
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /root/run/my-gatsby-site/node_modules/babel-plugin-polyfill-corejs2
npm ERR! dest /root/run/my-gatsby-site/node_modules/.babel-plugin-polyfill-corejs2-YQ4o3HHH
npm ERR! errno -39
npm ERR! ENOTEMPTY: directory not empty, rename '/root/run/my-gatsby-site/node_modules/babel-plugin-polyfill-corejs2' -> '/root/run/my-gatsby-site/node_modules/.babel-plugin-polyfill-corejs2-YQ4o3HHH'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-03-02T09_03_13_243Z-debug-0.log
[root@localhost my-gatsby-site]# rm -rf /root/run/my-gatsby-site/node_modules/.babel-plugin-polyfill-corejs2-YQ4o3HHH
[root@localhost my-gatsby-site]# npm install
...
somebody solve It?
[root@localhost my-gatsby-site]# cat /etc/redhat-release
CentOS Stream release 9
[root@localhost my-gatsby-site]# npm -v
9.5.0
[root@localhost my-gatsby-site]# node -v
v18.14.2
[root@localhost my-gatsby-site]# uname -a
Linux localhost 4.19.113-perf-g1a19ce2a6a79 #1 SMP PREEMPT Thu Sep 29 10:51:36 CST 2022 aarch64 aarch64 aarch64 GNU/Linux
We have been seeing this quite a bit for our applications. Whenever an engineer is not on VPN and does an npm install
, presses ctrl+c
to terminate the forever hanging process, and then tries to npm install
again after connecting to vpn this error is often reproducible. It seems to matter how long you wait until you ctrl+c
. If you do it quickly, no error. If you do it after waiting some time, it will most likely appear and you need to nuke your node_modules
.
Took me a while to figure out, but it also happens when running two or more npm install
concurrently. npm is apparently not concurrency-safe.
It seems like I just stumbled upon this, while npm upgrade
-ing the dependencies of my repo over a shaky internet connection.
$ npm upgrade
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! errno ERR_SOCKET_TIMEOUT
npm ERR! network Invalid response body while trying to fetch https://registry.npmjs.org/@babel%2fplugin-transform-property-literals: Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in: /Users/j/.npm/_logs/2023-10-17T16_39_28_302Z-debug-0.log
$ npm upgrade
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in: /Users/j/.npm/_logs/2023-10-17T16_42_22_533Z-debug-0.log
$ npm upgrade
npm ERR! code ENOTEMPTY
npm ERR! syscall rename
npm ERR! path /Users/j/web/chutney/node_modules/@babel/traverse
npm ERR! dest /Users/j/web/chutney/node_modules/@babel/.traverse-v3uDsTEY
npm ERR! errno -66
npm ERR! ENOTEMPTY: directory not empty, rename '/Users/j/web/chutney/node_modules/@babel/traverse' -> '/Users/j/web/chutney/node_modules/@babel/.traverse-v3uDsTEY'
npm ERR! A complete log of this run can be found in: /Users/j/.npm/_logs/2023-10-17T16_43_07_546Z-debug-0.log
Unfortunately I don't have the referenced log files, a subsequent successful npm upgrade
seems to have deleted them.
This is a common issue, it happens regularly when npm install
fails (even though we've come a long way since npm 3)
See https://stackoverflow.com/questions/67991537/npm-install-error-enotempty-directory-not-empty
I really wish that:
- npm automatically recognized these folders and just delete them anyway
- npm had a
--please-do-what-you-gotta-do
flag to force the deletion
The solution right now involves deleting the entire node_modules folder and reinstalling from scratch
It seems like this and a bunch of other pain points (e.g. #4028) can result from an unreliable network connection.
A good way to catch this might be to incorporate tests which simulate network disconnects in the middle of operations and then check to see if npm
can recover gracefully.