N: export N_NODE_MIRROR is useless for sudo operation

Created on 21 Aug 2019  路  4Comments  路  Source: tj/n

export N_NODE_MIRROR=https://npm.taobao.org/mirrors/node & sudo n 10.16.3

it still fetch node from https://nodejs.org

Most helpful comment

You need to tell sudo that you want to use the existing environment variables.

For example, on Mac looks like:

export N_NODE_MIRROR=https://npm.taobao.org/mirrors/node
sudo -E n 10.16.3

From sudo man page:

-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing
environment variables. The security policy may return an error if the user does
not have permission to preserve the environment.

All 4 comments

You need to tell sudo that you want to use the existing environment variables.

For example, on Mac looks like:

export N_NODE_MIRROR=https://npm.taobao.org/mirrors/node
sudo -E n 10.16.3

From sudo man page:

-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing
environment variables. The security policy may return an error if the user does
not have permission to preserve the environment.

ok thanks for your help

maybe you should add those to readme.md (?)

You need to tell sudo that you want to use the existing environment variables.

For example, on Mac looks like:

export N_NODE_MIRROR=https://npm.taobao.org/mirrors/node
sudo -E n 10.16.3

From sudo man page:

-E, --preserve-env
Indicates to the security policy that the user wishes to preserve their existing
environment variables. The security policy may return an error if the user does
not have permission to preserve the environment.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings