npm proxy error
bakeDong1 opened this issue · 12 comments
when set npm proxy get error
==> default: Configuring proxy for npm...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/usr/bin/npm config --global set noproxy foo
Stdout from the command:
Stderr from the command:
npm ERR! obj[key].join is not a function
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-06-18T01_15_45_591Z-debug.log
and log is
0 verbose cli [
0 verbose cli '/usr/bin/node',
0 verbose cli '/usr/bin/npm',
0 verbose cli 'config',
0 verbose cli '--global',
0 verbose cli 'set',
0 verbose cli 'noproxy',
0 verbose cli 'foo'
0 verbose cli ]
1 info using npm@7.17.0
2 info using node@v16.3.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 1ms
6 timing config:load:builtin Completed in 1ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/home/vagrant/.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:/root/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/usr/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 1ms
17 timing config:load:setEnvs Completed in 0ms
18 timing config:load Completed in 6ms
19 timing npm:load:configload Completed in 6ms
20 timing npm:load:setTitle Completed in 1ms
21 timing npm:load:setupLog Completed in 0ms
22 timing npm:load:cleanupLog Completed in 1ms
23 timing npm:load:configScope Completed in 0ms
24 timing npm:load:projectScope Completed in 1ms
25 timing npm:load Completed in 10ms
26 timing config:load:flatten Completed in 2ms
27 info config set "noproxy" "foo"
28 verbose stack TypeError: obj[key].join is not a function
28 verbose stack at Definition.flatten (/usr/lib/node_modules/npm/lib/utils/config/definitions.js:1212:36)
28 verbose stack at Config.flatten (/usr/lib/node_modules/npm/lib/utils/config/flatten.js:15:11)
28 verbose stack at Config.get flat [as flat] (/usr/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:220:21)
28 verbose stack at Object.get flatOptions [as flatOptions] (/usr/lib/node_modules/npm/lib/npm.js:216:13)
28 verbose stack at lastCheckedFile (/usr/lib/node_modules/npm/lib/utils/update-notifier.js:26:15)
28 verbose stack at updateTimeout (/usr/lib/node_modules/npm/lib/utils/update-notifier.js:39:19)
28 verbose stack at module.exports (/usr/lib/node_modules/npm/lib/utils/update-notifier.js:123:3)
29 verbose cwd /home/vagrant
30 verbose Linux 5.12.10-arch1-1
31 verbose argv "/usr/bin/node" "/usr/bin/npm" "config" "--global" "set" "noproxy" "foo"
32 verbose node v16.3.0
33 verbose npm v7.17.0
34 error obj[key].join is not a function
35 verbose exit 1
is npm 1.7 change config noproxy format ?
After extensive review, I'm having a hard time trying to understand if this is an issue with vagrant-proxyconf? I'm no expert with NPM and node and I'm afraid I cannot reproduce this issue without more information.
FWIW, the reason I say it doesn't appear to be vagrant-proxyconf is because of these lines in your log file.
28 verbose stack TypeError: obj[key].join is not a function
28 verbose stack at Definition.flatten (/usr/lib/node_modules/npm/lib/utils/config/definitions.js:1212:36)
28 verbose stack at Config.flatten (/usr/lib/node_modules/npm/lib/utils/config/flatten.js:15:11)
28 verbose stack at Config.get flat [as flat] (/usr/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:220:21)
28 verbose stack at Object.get flatOptions [as flatOptions] (/usr/lib/node_modules/npm/lib/npm.js:216:13)
28 verbose stack at lastCheckedFile (/usr/lib/node_modules/npm/lib/utils/update-notifier.js:26:15)
28 verbose stack at updateTimeout (/usr/lib/node_modules/npm/lib/utils/update-notifier.js:39:19)
28 verbose stack at module.exports (/usr/lib/node_modules/npm/lib/utils/update-notifier.js:123:3)
-
Can you please provide your Vagrantfile?
-
What version of vagrant are you using?
vagrant --version
-
What version vagrant-proxyconf do you have installed?
vagrant plugin list
vagrant version is 2.2.14
vagrant-proxyconf is 2.0.10
it's look like npm config set noproxy require array param,but vagrant-proxyconf set foo
Please provide a copy of your Vagrantfile.
Also, please provide supporting documentation and a way to reproduce this.
Vagrantfile is
Vagrant.configure("2") do |config|
config.vm.box = "archlinux/archlinux"
config.vm.network "private_network", ip: "192.168.33.12"
end
the way to reproduce this.
vagrant up
vagrant ssh
#this will install npm
sudo pacman -S npm
exit
# restart will get proxy npm error
vagrant reload
Thank you for the info.
Again, I'm not sure this is a bug in vagrant-proxyconf and after reviewing the code it appears it's been this way since 2014 and no code changes have been introduced to vagrant-proxyconf outside a formatting refactor. I cannot reproduce this error using centos/7
as a box. I also don't test things on Archlinux as I find Archlinux a bit of a odd beast when it comes to linux. Perhaps there is bug in either Arch or NPM that is causing this issue?
2014-11-18 23:19:45 +0100 40) @machine.communicate.sudo("#{npm_path} config --global set #{key} foo")
Also as stated before I'm not all that familiar with Node and NPM. It doesn't mean I won't help, it just means that since I'm a OSS developer I also rely on the community to help provide workarounds and or provide a good working example.
For example on CentOS 7, npm is installed from EPEL and is version 3.10.10
and on Arch it appears to be 7.17.0
I'm not about to comb through all the NPM changelogs to find the exact reason. I'm hoping that we can work together and I hope that you can help by finding the solution since you know NPM better than I.
I'm just trying to help maintain this plugin. I'm not the original author of all the features this plugin supports. I'm just trying to do the best I can until Vagrant switches from ruby to GO. As of which time, I will no longer contribute to this plugin when it switches to GO.
FWIW, I used the archlinux/archlinux
box from vagrant cloud and I'm able to reproduce the error but as stated above I don't have a workaround to this issue and it appears to be more npm related than vagrant-proxyconf. Please help by providing a working solution to this problem so that I can update the code and tests.
I'm not going to spend anymore time troubleshooting why NPM doesn't work.
i try to set proxy for npm and i get this.
npm config set proxy=foo
npm WARN invalid config proxy="foo" set in /root/.npmrc
npm WARN invalid config Must be full url with "http://"
npm WARN config omitting invalid config values
it's look's like proxy value must be full url ,so i try set proxy null ,and it worked.
npm config set proxy=null
npm config list
; "user" config from /root/.npmrc
proxy = null
; node bin location = /usr/bin/node
; cwd = /home/vagrant
; HOME = /root
Hi @bakeDong1 - Thank you for providing that information. I'll get back to you in a few days when I have some free time.
Sorry, I've not had time to get to this like I hoped. I'll do my best and at lest provide a better status before the end of the week.
Hey @codylane - sorry I haven't had time to help as much as I've wanted to. I think I can help with this, though.
@bakeDong1 - This issue with npm config set noproxy <value>
seems to be a bug introduced in npm@>=7.16.x
.
You can verify yourself, too, by using nvm
in your archlinux VM to easily switch between versions without messing up the local/machine install.
# Install NVM (it'll tell you to open a new session/terminal after install)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash
### restart session / terminal ###
# Install and use latest stable node (16.4.2 as of now), which includes latest npm (7.18.1 as of now)
nvm install stable
# Watch noproxy fail...
npm config set noproxy foo
# npm ERR! obj[key].join is not a function...
# Install and use node 15.14.x which uses npm 7.15.1 as of now
nvm install 15.14
# Watch noproxy work as expected
npm config set noproxy foo
npm config ls | grep noproxy
# noproxy = ["foo"]
From what I've read, installing older versions of things using pacman
isn't easy, so maybe you can use nvm
or n
to manage node versions if possible? Either that or wait until npm
fixes this bug, which seems to have a PR already.
From what I can tell this isn't really related to vagrant-proxyconf
and can be closed.
Right on @chucknelson, I appreciate the assist here and to provide some very helpful and accurate information. Major kudos. I hope you are well and thanks again for your help with this project.
Closing per #236 (comment)