psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Error: require() of ES modules is not supported when importing node-fetch
Could not GET 'play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
The unauthenticated git protocol on port 9418 is no longer supported
CentOS through a VM - no URLs in mirrorlist
Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
ESlint - Error: Must use import to load ES Module
throwError(error) is now deprecated, but there is no new Error(HttpErrorResponse)
How to open emulators in different windows at Android Studio (Bumblebee | 2021.1.1)?
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directoryError: require() of ES modules is not supported when importing node-fetchCould not GET 'play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad GatewayThe unauthenticated git protocol on port 9418 is no longer supportedCentOS through a VM - no URLs in mirrorlistJava, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMEDSpringboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'ESlint - Error: Must use import to load ES ModulethrowError(error) is now deprecated, but there is no new Error(HttpErrorResponse)How to open emulators in different windows at Android Studio (Bumblebee | 2021.1.1)?
QUESTION
psql: error: connection to server on socket "/tmp/.s.PGSQL.5432" failed: No such file or directory
Asked 2022-Apr-04 at 15:46
Not really sure what caused this but most likely exiting the terminal while my rails server which was connected to PostgreSQL database was closed (not a good practice I know but lesson learned!)
I've already tried the following:
Rebooting my machine (using MBA M1 2020)
Restarting PostgreSQL using homebrew brew services restart postgresql
Re-installing PostgreSQL using Homebrew
Updating PostgreSQL using Homebrew
I also tried following this link but when I run cd Library/Application\ Support/Postgres terminal tells me Postgres folder doesn't exist, so I'm kind of lost already. Although I have a feeling that deleting postmaster.pid would really fix my issue. Any help would be appreciated!
ANSWER
Answered 2022-Jan-13 at 15:19
Resetting PostgreSQL
My original answer only included the troubleshooting steps below, and a workaround. I now decided to properly fix it via brute force by removing all clusters and reinstalling, since I didn't have any data there to keep. It was something along these lines, on my Ubuntu 21.04 system:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9
And sudo -u postgres psql works fine. The service was started automatically but it can be done manually with sudo systemctl start postgresql.
Incidentally, I can recommend the PostgreSQL docker image, which eliminates the need to bother with a local installation.
Troubleshooting
Although I cannot provide an answer to your specific problem, I thought I'd share my troubleshooting steps, hoping that it might be of some help. It seems that you are on Mac, whereas I am running Ubuntu 21.04, so expect things to be different.
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12
I checked what unix sockets I had in that directory:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21
Makes sense, there is a socket for 5433 not 5432. I confirmed this by running:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21$ pg_lsclusters
22Ver Cluster Port Status Owner Data directory Log file
2312 main 5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
2414 main 5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
25
This explains how it got into this mess on my system. The default port is 5432, but after I upgraded from version 12 to 14, the server was setup to listen to 5433, presumably because it considered 5432 as already taken. Two alternatives here, get the server to listen on 5432 which is the client's default, or get the client to use 5433.
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21$ pg_lsclusters
22Ver Cluster Port Status Owner Data directory Log file
2312 main 5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
2414 main 5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
25$ sudo su postgres -c "psql --port=5433"
26psql (14.0 (Ubuntu 14.0-1.pgdg21.04+1))
27Type "help" for help.
2829postgres=#
30
It worked! Now, to make it permanent I'm supposed to put this setting on a psqlrc or ~/.psqlrc file. The thin documentation on this (under "Files") was not helpful to me as I was not sure on the syntax and my attempts did not change the client's default, so I moved on.
To change the server I looked for the postgresql.conf mentioned in the documentation but could not find the file. I did however see /var/lib/postgresql/14/main/postgresql.auto.conf so I created it on the same directory with the content:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21$ pg_lsclusters
22Ver Cluster Port Status Owner Data directory Log file
2312 main 5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
2414 main 5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
25$ sudo su postgres -c "psql --port=5433"
26psql (14.0 (Ubuntu 14.0-1.pgdg21.04+1))
27Type "help" for help.
2829postgres=#
30port = 5432
31
Restarted the server: sudo systemctl restart postgresql
But the error persisted because, as the logs confirmed, the port did not change:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21$ pg_lsclusters
22Ver Cluster Port Status Owner Data directory Log file
2312 main 5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
2414 main 5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
25$ sudo su postgres -c "psql --port=5433"
26psql (14.0 (Ubuntu 14.0-1.pgdg21.04+1))
27Type "help" for help.
2829postgres=#
30port = 5432
31$ tail /var/log/postgresql/postgresql-14-main.log
32...
332021-10-29 16:36:12.195 UTC [25236] LOG: listening on IPv4 address "127.0.0.1", port 5433
342021-10-29 16:36:12.198 UTC [25236] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
352021-10-29 16:36:12.204 UTC [25237] LOG: database system was shut down at 2021-10-29 16:36:12 UTC
362021-10-29 16:36:12.210 UTC [25236] LOG: database system is ready to accept connections
37
After other attempts did not succeed, I eventually decided to use a workaround: to redirect the client's requests on 5432 to 5433:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21$ pg_lsclusters
22Ver Cluster Port Status Owner Data directory Log file
2312 main 5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
2414 main 5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
25$ sudo su postgres -c "psql --port=5433"
26psql (14.0 (Ubuntu 14.0-1.pgdg21.04+1))
27Type "help" for help.
2829postgres=#
30port = 5432
31$ tail /var/log/postgresql/postgresql-14-main.log
32...
332021-10-29 16:36:12.195 UTC [25236] LOG: listening on IPv4 address "127.0.0.1", port 5433
342021-10-29 16:36:12.198 UTC [25236] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
352021-10-29 16:36:12.204 UTC [25237] LOG: database system was shut down at 2021-10-29 16:36:12 UTC
362021-10-29 16:36:12.210 UTC [25236] LOG: database system is ready to accept connections
37ln -s /var/run/postgresql/.s.PGSQL.5433 /var/run/postgresql/.s.PGSQL.5432
38
This is what I have now:
1sudo pg_dropcluster --stop 12 main
2sudo pg_dropcluster --stop 14 main
3sudo apt remove postgresql-14
4sudo apt purge postgresql*
5sudo apt install postgresql-14
6$ pg_lsclusters
7Ver Cluster Port Status Owner Data directory Log file
814 main 5432 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
9$ sudo su postgres -c "psql"
10psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
11 Is the server running locally and accepting connections on that socket?
12$ ls -lah /var/run/postgresql/
13total 8.0K
14drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
15drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
16drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
17drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
18-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
19srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
20-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
21$ pg_lsclusters
22Ver Cluster Port Status Owner Data directory Log file
2312 main 5432 down,binaries_missing postgres /var/lib/postgresql/12/main /var/log/postgresql/postgresql-12-main.log
2414 main 5433 online postgres /var/lib/postgresql/14/main /var/log/postgresql/postgresql-14-main.log
25$ sudo su postgres -c "psql --port=5433"
26psql (14.0 (Ubuntu 14.0-1.pgdg21.04+1))
27Type "help" for help.
2829postgres=#
30port = 5432
31$ tail /var/log/postgresql/postgresql-14-main.log
32...
332021-10-29 16:36:12.195 UTC [25236] LOG: listening on IPv4 address "127.0.0.1", port 5433
342021-10-29 16:36:12.198 UTC [25236] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5433"
352021-10-29 16:36:12.204 UTC [25237] LOG: database system was shut down at 2021-10-29 16:36:12 UTC
362021-10-29 16:36:12.210 UTC [25236] LOG: database system is ready to accept connections
37ln -s /var/run/postgresql/.s.PGSQL.5433 /var/run/postgresql/.s.PGSQL.5432
38$ ls -lah /var/run/postgresql/
39total 8.0K
40drwxrwsr-x 4 postgres postgres 160 Oct 29 16:40 .
41drwxr-xr-x 36 root root 1.1K Oct 29 14:08 ..
42drwxr-s--- 2 postgres postgres 40 Oct 29 14:33 12-main.pg_stat_tmp
43drwxr-s--- 2 postgres postgres 120 Oct 29 16:59 14-main.pg_stat_tmp
44-rw-r--r-- 1 postgres postgres 6 Oct 29 16:36 14-main.pid
45lrwxrwxrwx 1 postgres postgres 33 Oct 29 16:40 .s.PGSQL.5432 -> /var/run/postgresql/.s.PGSQL.5433
46srwxrwxrwx 1 postgres postgres 0 Oct 29 16:36 .s.PGSQL.5433
47-rw------- 1 postgres postgres 70 Oct 29 16:36 .s.PGSQL.5433.lock
48
This means I can now just run psql without having to explicitly set the port to 5433. Now, this is a hack and I would not recommend it. But in my development system I am happy with it for now, because I don't have more time to spend on this. This is why I shared the steps and the links so that you can find a proper solution for your case.
Error: require() of ES modules is not supported when importing node-fetch
Asked 2022-Mar-28 at 07:04
I'm creating a program to analyze security camera streams and got stuck on the very first line. At the moment my .js file has nothing but the import of node-fetch and it gives me an error message. What am I doing wrong?
Running Ubuntu 20.04.2 LTS in Windows Subsystem for Linux.
Node version:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3
node-fetch package version:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
45node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
89keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
1011dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
1617dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
1920maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
2526dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
2829published 3 days ago by endless <jimmy@warting.se>
30
esm package version:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
45node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
89keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
1011dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
1617dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
1920maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
2526dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
2829published 3 days ago by endless <jimmy@warting.se>
30user@MYLLYTIN:~/CAMSERVER$ npm v esm
3132esm@3.2.25 | MIT | deps: none | versions: 140
33Tomorrow's ECMAScript modules today!
34https://github.com/standard-things/esm#readme
3536keywords: commonjs, ecmascript, export, import, modules, node, require
3738dist
39.tarball: https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
40.shasum: 342c18c29d56157688ba5ce31f8431fbb795cc10
41.integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
42.unpackedSize: 308.6 kB
4344maintainers:
45- jdalton <john.david.dalton@gmail.com>
4647dist-tags:
48latest: 3.2.25
4950published over a year ago by jdalton <john.david.dalton@gmail.com>
51
Contents of the .js file (literally nothing but the import):
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
45node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
89keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
1011dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
1617dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
1920maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
2526dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
2829published 3 days ago by endless <jimmy@warting.se>
30user@MYLLYTIN:~/CAMSERVER$ npm v esm
3132esm@3.2.25 | MIT | deps: none | versions: 140
33Tomorrow's ECMAScript modules today!
34https://github.com/standard-things/esm#readme
3536keywords: commonjs, ecmascript, export, import, modules, node, require
3738dist
39.tarball: https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
40.shasum: 342c18c29d56157688ba5ce31f8431fbb795cc10
41.integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
42.unpackedSize: 308.6 kB
4344maintainers:
45- jdalton <john.david.dalton@gmail.com>
4647dist-tags:
48latest: 3.2.25
4950published over a year ago by jdalton <john.david.dalton@gmail.com>
51user@MYLLYTIN:~/CAMSERVER$ cat server.js
52import fetch from "node-fetch";
53
Result:
1user@MYLLYTIN:~/CAMSERVER$ node -v
2v14.17.6
3user@MYLLYTIN:~/CAMSERVER$ npm v node-fetch
45node-fetch@3.0.0 | MIT | deps: 2 | versions: 63
6A light-weight module that brings Fetch API to node.js
7https://github.com/node-fetch/node-fetch
89keywords: fetch, http, promise, request, curl, wget, xhr, whatwg
1011dist
12.tarball: https://registry.npmjs.org/node-fetch/-/node-fetch-3.0.0.tgz
13.shasum: 79da7146a520036f2c5f644e4a26095f17e411ea
14.integrity: sha512-bKMI+C7/T/SPU1lKnbQbwxptpCrG9ashG+VkytmXCPZyuM9jB6VU+hY0oi4lC8LxTtAeWdckNCTa3nrGsAdA3Q==
15.unpackedSize: 75.9 kB
1617dependencies:
18data-uri-to-buffer: ^3.0.1 fetch-blob: ^3.1.2
1920maintainers:
21- endless <jimmy@warting.se>
22- bitinn <bitinn@gmail.com>
23- timothygu <timothygu99@gmail.com>
24- akepinski <npm@kepinski.ch>
2526dist-tags:
27latest: 3.0.0 next: 3.0.0-beta.10
2829published 3 days ago by endless <jimmy@warting.se>
30user@MYLLYTIN:~/CAMSERVER$ npm v esm
3132esm@3.2.25 | MIT | deps: none | versions: 140
33Tomorrow's ECMAScript modules today!
34https://github.com/standard-things/esm#readme
3536keywords: commonjs, ecmascript, export, import, modules, node, require
3738dist
39.tarball: https://registry.npmjs.org/esm/-/esm-3.2.25.tgz
40.shasum: 342c18c29d56157688ba5ce31f8431fbb795cc10
41.integrity: sha512-U1suiZ2oDVWv4zPO56S0NcR5QriEahGtdN2OR6FiOG4WJvcjBVFB0qI4+eKoWFH483PKGuLuu6V8Z4T5g63UVA==
42.unpackedSize: 308.6 kB
4344maintainers:
45- jdalton <john.david.dalton@gmail.com>
4647dist-tags:
48latest: 3.2.25
4950published over a year ago by jdalton <john.david.dalton@gmail.com>
51user@MYLLYTIN:~/CAMSERVER$ cat server.js
52import fetch from "node-fetch";
53user@MYLLYTIN:~/CAMSERVER$ node -r esm server.js
54/home/user/CAMSERVER/node_modules/node-fetch/src/index.js:1
55Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/user/CAMSERVER/node_modules/node-fetch/src/index.js
56require() of ES modules is not supported.
57require() of /home/user/CAMSERVER/node_modules/node-fetch/src/index.js from /home/user/CAMSERVER/server.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
58Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/user/CAMSERVER/node_modules/node-fetch/package.json.
5960 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1089:13) {
61 code: 'ERR_REQUIRE_ESM'
62}
63user@MYLLYTIN:~/CAMSERVER$
64
ANSWER
Answered 2022-Feb-25 at 00:00
Use ESM syntax, also use one of these methods before running the file.
specify "type":"module" in package.json
Or use this flag --input-type=module when running the file
Could not GET 'play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
Asked 2022-Mar-28 at 07:02
I have a project which was running well yesterday, but today I find this problem:
Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
Could not resolve com.google.android.gms:play-services-location:16.+.
Required by:
project :app > project :location
> Failed to list versions for com.google.android.gms:play-services-location.
> Unable to load Maven meta-data from https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml.
> Could not get resource 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'.
> Could not GET 'https://google.bintray.com/exoplayer/com/google/android/gms/play-services-location/maven-metadata.xml'. Received status code 502 from server: Bad Gateway
acutely I'm using classpath 'com.android.tools.build:gradle:4.1.0'with distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip
I have followed this question
and I upgraded 'com.android.tools.build:gradle:4.1.0' to classpath 'com.android.tools.build:gradle:4.2.0' then I changed distributionUrl=https://services.gradle.org/distributions/gradle-6.5-bin.zip to distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip but I still got the error.
You can try using offline mode if you're using Android Studio, then it will use the cached version of this library if you have it until it is fixed.
UPD. I switched to an alpha version of a flutter lib which caused this (workmanager) and it works well now. As far as I understand it was depending on an old version of Android Room library which is not available anymore since Bintray is not available. The new version of Room is available as it's being downloaded thorough another link. So for you the solution could be updating to a newer version of Flutter location package or forking it and changing the version of play-services-location to the most recent one.
This is the full brownout period where we’ll temporarily stop accepting the deprecated key and signature types, ciphers, and MACs, and the unencrypted Git protocol.
This will help clients discover any lingering use of older keys or old URLs.
Second, check your package.json dependencies for any git:// URL, as in this example, fixed in this PR.
There was a 4-month warning.
The entire Internet has been moving away from unauthenticated, unencrypted protocols for a decade, it's not like this is a huge surprise.
Personally, I consider it less an "issue" and more "detecting unmaintained dependencies".
Plus, this is still only the brownout period, so the protocol will only be disabled for a short period of time, allowing developers to discover the problem.
You can also use SSH, but GitHub Security reminds us that, as of March 15th, 2022, GitHub stopped accepting DSA keys. RSA keys uploaded after Nov 2, 2021 will work only with SHA-2 signatures.
The deprecated MACs, ciphers, and unencrypted Git protocol are permanently disabled.
I am trying to run a CentOS 8 server through VirtualBox (6.1.30) (Vagrant), which worked just fine yesterday for me, but today I tried running a sudo yum update. I keep getting this error for some reason:
1[vagrant@192.168.38.4] ~ >> sudo yum update
2CentOS Linux 8 - AppStream 71 B/s | 38 B 00:00
3Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
4
I already tried to change the namespaces on /etc/resolve.conf, remove the DNF folders and everything. On other computers, this works just fine, so I think the problem is with my host machine. I also tried to reset the network settings (I am on a Windows 10 host), without success either. It's not a DNS problem; it works just fine.
After I reinstalled Windows, I still have the same error in my VM.
File dnf.log:
1[vagrant@192.168.38.4] ~ >> sudo yum update
2CentOS Linux 8 - AppStream 71 B/s | 38 B 00:00
3Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
42022-01-31T15:28:03+0000 INFO --- logging initialized ---
52022-01-31T15:28:03+0000 DDEBUG timer: config: 2 ms
62022-01-31T15:28:03+0000 DEBUG Loaded plugins: builddep, changelog, config-manager, copr, debug, debuginfo-install, download, generate_completion_cache, groups-manager, needs-restarting, playground, repoclosure, repodiff, repograph, repomanage, reposync
72022-01-31T15:28:03+0000 DEBUG YUM version: 4.4.2
82022-01-31T15:28:03+0000 DDEBUG Command: yum update
92022-01-31T15:28:03+0000 DDEBUG Installroot: /
102022-01-31T15:28:03+0000 DDEBUG Releasever: 8
112022-01-31T15:28:03+0000 DEBUG cachedir: /var/cache/dnf
122022-01-31T15:28:03+0000 DDEBUG Base command: update
132022-01-31T15:28:03+0000 DDEBUG Extra commands: ['update']
142022-01-31T15:28:03+0000 DEBUG User-Agent: constructed: 'libdnf (CentOS Linux 8; generic; Linux.x86_64)'
152022-01-31T15:28:05+0000 DDEBUG Cleaning up.
162022-01-31T15:28:05+0000 SUBDEBUG
17Traceback (most recent call last):
18 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 574, in load
19 ret = self._repo.load()
20 File "/usr/lib64/python3.6/site-packages/libdnf/repo.py", line 397, in load
21 return _repo.Repo_load(self)
22libdnf._error.Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
2324During handling of the above exception, another exception occurred:
2526Traceback (most recent call last):
27 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 67, in main
28 return _main(base, args, cli_class, option_parser_class)
29 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 106, in _main
30 return cli_run(cli, base)
31 File "/usr/lib/python3.6/site-packages/dnf/cli/main.py", line 122, in cli_run
32 cli.run()
33 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 1050, in run
34 self._process_demands()
35 File "/usr/lib/python3.6/site-packages/dnf/cli/cli.py", line 740, in _process_demands
36 load_available_repos=self.demands.available_repos)
37 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 394, in fill_sack
38 self._add_repo_to_sack(r)
39 File "/usr/lib/python3.6/site-packages/dnf/base.py", line 137, in _add_repo_to_sack
40 repo.load()
41 File "/usr/lib/python3.6/site-packages/dnf/repo.py", line 581, in load
42 raise dnf.exceptions.RepoError(str(e))
43dnf.exceptions.RepoError: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
442022-01-31T15:28:05+0000 CRITICAL Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist
45
Java, Intellij IDEA problem Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
Asked 2022-Mar-26 at 15:23
I have newly installed
1IntelliJ IDEA 2021.2 (Ultimate Edition)
2Build #IU-212.4746.92, built on July 27, 2021
3Licensed to XXXXXX
4Subscription is active until August 15, 2021.
5Runtime version: 11.0.11+9-b1504.13 amd64
6VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
7Linux 5.4.0-80-generic
8GC: G1 Young Generation, G1 Old Generation
9Memory: 2048M
10Cores: 3
1112Kotlin: 212-1.5.10-release-IJ4746.92
13Current Desktop: X-Cinnamon
14
I cloned project I work with on other workstation without issues, but cannot start any class with main method and IDEA says:
1IntelliJ IDEA 2021.2 (Ultimate Edition)
2Build #IU-212.4746.92, built on July 27, 2021
3Licensed to XXXXXX
4Subscription is active until August 15, 2021.
5Runtime version: 11.0.11+9-b1504.13 amd64
6VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
7Linux 5.4.0-80-generic
8GC: G1 Young Generation, G1 Old Generation
9Memory: 2048M
10Cores: 3
1112Kotlin: 212-1.5.10-release-IJ4746.92
13Current Desktop: X-Cinnamon
14Abnormal build process termination:
15/usr/lib/jvm/java-1.8.0-openjdk-amd64/bin/java -Xmx700m -Djava.awt.headless=true -Djava.endorsed.dirs=\"\" -Dcompile.parallel=false -Drebuild.on.dependency.change=true -Djdt.compiler.useSingleThread=true -Daether.connector.resumeDownloads=false -Dio.netty.initialSeedUniquifier=-5972351880001011455 -Dfile.encoding=UTF-8 -Duser.language=en -Duser.country=US -Didea.paths.selector=IntelliJIdea2021.2 -Didea.home.path=/home/pm/idea-IU-212.4746.92 -Didea.config.path=/home/pm/.config/JetBrains/IntelliJIdea2021.2 -Didea.plugins.path=/home/pm/.local/share/JetBrains/IntelliJIdea2021.2 -Djps.log.dir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/log/build-log -Djps.fallback.jdk.home=/home/pm/idea-IU-212.4746.92/jbr -Djps.fallback.jdk.version=11.0.11 -Dio.netty.noUnsafe=true -Djava.io.tmpdir=/home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server/rfg-survey-api_cc70fc05/_temp_ -Djps.backward.ref.index.builder=true -Djps.track.ap.dependencies=false --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED --add-opens=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED -Dtmh.instrument.annotations=true -Dtmh.generate.line.numbers=true -Dkotlin.incremental.compilation=true -Dkotlin.incremental.compilation.js=true -Dkotlin.daemon.enabled -Dkotlin.daemon.client.alive.path=\"/tmp/kotlin-idea-12426594439704512301-is-running\" -classpath /home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-launcher.jar:/usr/lib/jvm/java-1.8.0-openjdk-amd64/lib/tools.jar org.jetbrains.jps.cmdline.Launcher /home/pm/idea-IU-212.4746.92/lib/slf4j.jar:/home/pm/idea-IU-212.4746.92/lib/idea_rt.jar:/home/pm/idea-IU-212.4746.92/lib/platform-api.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-file-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/forms_rt.jar:/home/pm/idea-IU-212.4746.92/lib/util.jar:/home/pm/idea-IU-212.4746.92/lib/annotations.jar:/home/pm/idea-IU-212.4746.92/lib/3rd-party.jar:/home/pm/idea-IU-212.4746.92/lib/kotlin-stdlib-jdk8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-connector-basic-1.3.3.jar:/home/pm/idea-IU-212.4746.92/lib/jna-platform.jar:/home/pm/idea-IU-212.4746.92/lib/protobuf-java-3.15.8.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders-6.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/javac2.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/aether-dependency-resolver.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-builders.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/jps-javac-extension-1.jar:/home/pm/idea-IU-212.4746.92/lib/jna.jar:/home/pm/idea-IU-212.4746.92/lib/jps-model.jar:/home/pm/idea-IU-212.4746.92/plugins/java/lib/maven-resolver-transport-http-1.3.3.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/jasper-v2-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-reflect.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/ant/lib/ant-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/uiDesigner/lib/jps/java-guiForms-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/eclipse/lib/eclipse-common.jar:/home/pm/idea-IU-212.4746.92/plugins/IntelliLang/lib/java-langInjection-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Groovy/lib/groovy-constants-rt.jar:/home/pm/idea-IU-212.4746.92/plugins/maven/lib/maven-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/gradle-java/lib/gradle-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/devkit/lib/devkit-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/javaFX/lib/javaFX-common.jar:/home/pm/idea-IU-212.4746.92/plugins/JavaEE/lib/javaee-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/webSphereIntegration/lib/jps/javaee-appServers-websphere-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/weblogicIntegration/lib/jps/javaee-appServers-weblogic-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/JPA/lib/jps/javaee-jpa-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-jps.jar:/home/pm/idea-IU-212.4746.92/plugins/Grails/lib/groovy-grails-compilerPatch.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/jps/kotlin-jps-plugin.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-jps-common.jar:/home/pm/idea-IU-212.4746.92/plugins/Kotlin/lib/kotlin-common.jar org.jetbrains.jps.cmdline.BuildMain 127.0.0.1 34781 9f0681bb-da2a-48db-8344-900ddeb29804 /home/pm/.cache/JetBrains/IntelliJIdea2021.2/compile-server
16Unrecognized option: --add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
17Error: Could not create the Java Virtual Machine.
18Error: A fatal exception has occurred. Program will exit.
19
I found other comment to check Lombok works and I see it is fine.
How to fix the problem?
ANSWER
Answered 2021-Jul-28 at 07:22
You are running the project via Java 1.8 and add the --add-opens option to the runner. However Java 1.8 does not support it.
So, the first option is to use Java 11 to run the project, as Java 11 can recognize this VM option.
Another solution is to find a place where --add-opens is added and remove it.
Check Run configuration in IntelliJ IDEA (VM options field) and Maven/Gradle configuration files for argLine (Maven) and jvmArgs (Gradle)
Springboot 2.6.0 / Spring fox 3 - Failed to start bean 'documentationPluginsBootstrapper'
Asked 2022-Mar-25 at 06:14
I'm trying to initiate a Springboot project using Open Jdk 15, Springboot 2.6.0, Springfox 3.
We are working on a project that replaced Netty as the webserver and used Jetty instead because we do not need a non-blocking environment.
In the code we depend primarily on Reactor API (Flux, Mono), so we can not remove org.springframework.boot:spring-boot-starter-webflux dependencies.