Sometimes the following error appears on Ubuntu Linux when building docker images for nodejs
projects and the project includes privately scoped node packages.
1
|
An unexpected error occurred: Request failed "404 Not Found" |
Initial workaround
The initial naive workaround we used was to manually change our DNS entry in /etc/resolv.conf to point to the local gateway.
/etc/resolv.conf
1 2 nameserver 10.0.0.1 search npm.ourdomain.com
Then manually stop the systemd-resolved service.
1
|
sudo service systemd-resolved stop |
Better workaround
We found a better solution to the problem in Stack Overflow.
First open the DHCP configuration file for editing:
1
|
$ sudo nano /etc/dhcp/dhclient.conf |
Then uncomment the following two lines and replace the default values with our DNS address and private NPM registry host. If we want to use as DNS 10.0.0.1 and host npm.ourdomain.com
, we would end up with the following lines:
1 2 |
supersede domain-name "npm.ourdomain.com"; prepend domain-name-servers 10.0.0.1; |
Finally, reboot Ubuntu and it should work like charm. If it still doesn’t, check the accepted answer in the SO post.