There wasn't too much wrong with your script:
setting a variable to the output of a command (i.e. Command Substitution) needs $() around the command. I am deliberately ignoring the existence of obsolete backticks for the same purpose, they are broken in several ways.
quote your variables when you use them.
e.g. if [ -z $p ] without quotes is guaranteed to be a syntax error if $p is actually empty because -z requires an argument. if [ -z "$p" ] will never cause an error because even an empty string is an argument.
Here's a minimally fixed version (also with superfluous semicolons removed):
p="$(sudo npm config get proxy)"
echo "$p"
if [ -z "$p" ] ; then
echo "delete"
sudo npm config delete proxy http://xxx.xx.xxx.xxx:8085
else
echo "set"
sudo npm config set proxy http://xxx.xx.xxx.xxx:8085
fi