Macos 安装vue-cli老是遇到Error EACCES permission denied, access ‘ usr local lib node_modules‘怎么办

  :
# Check if version is an existing changeset
elif ! nvm_download -o /dev/null "$(nvm_source "script-nvm-exec")"; then
  nvm_echo >&2 "Failed to find '$NVM_VERSION' version."
  exit 1
fi

fi

local fetch_error
if [ -d “$INSTALL_DIR/.git” ]; then
# Updating repo
nvm_echo “=> nvm is already installed in $INSTALL_DIR, trying to update using git”
command printf ‘\r=> ’
fetch_error=“Failed to update nvm with $NVM_VERSION, run ‘git fetch’ in $INSTALL_DIR yourself.”
else
fetch_error="Failed to fetch origin with N V M V E R S I O N . P l e a s e r e p o r t t h i s ! " n v m e c h o " = > D o w n l o a d i n g n v m f r o m g i t t o ′ NVM_VERSION. Please report this!" nvm_echo "=> Downloading nvm from git to ' NVMVERSION.Pleasereportthis!"nvmecho"=>DownloadingnvmfromgittoINSTALL_DIR’"
command printf '\r=> ’
mkdir -p “ I N S T A L L D I R " i f [ " {INSTALL_DIR}" if [ " INSTALLDIR"if["(ls -A “KaTeX parse error: Expected 'EOF', got '#' at position 32: … ]; then #̲ Initializing r…{INSTALL_DIR}” || {
nvm_echo >&2 ‘Failed to initialize nvm repo. Please report this!’
exit 2
}
command git --git-dir=” I N S T A L L D I R / . g i t " r e m o t e a d d o r i g i n " {INSTALL_DIR}/.git" remote add origin " INSTALLDIR/.git"remoteaddorigin"(nvm_source)" 2> /dev/null
|| command git --git-dir=“ I N S T A L L D I R / . g i t " r e m o t e s e t − u r l o r i g i n " {INSTALL_DIR}/.git" remote set-url origin " INSTALLDIR/.git"remoteseturlorigin"(nvm_source)” || {
nvm_echo >&2 ‘Failed to add remote “origin” (or set the URL). Please report this!’
exit 2
}
else
# Cloning repo
command git clone “ ( n v m s o u r c e ) " − − d e p t h = 1 " (nvm_source)" --depth=1 " (nvmsource)"depth=1"{INSTALL_DIR}” || {
nvm_echo >&2 ‘Failed to clone nvm repo. Please report this!’
exit 2
}
fi
fi

Try to fetch tag

if command git --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” fetch origin tag “$NVM_VERSION” --depth=1 2>/dev/null; then
:

Fetch given version

elif ! command git --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” fetch origin “KaTeX parse error: Expected 'EOF', got '&' at position 44: … nvm_echo >&̲2 "fetch_error”
exit 1
fi
command git -c advice.detachedHead=false --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” checkout -f --quiet FETCH_HEAD || {
nvm_echo >&2 “Failed to checkout the given version KaTeX parse error: Expected 'EOF', got '}' at position 48: …" exit 2 }̲ if [ -n "(command git --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” show-ref refs/heads/master)” ]; then
if command git --no-pager --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” branch --quiet 2>/dev/null; then
command git --no-pager --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” branch --quiet -D master >/dev/null 2>&1
else
nvm_echo >&2 “Your version of git is out of date. Please update it!”
command git --no-pager --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” branch -D master >/dev/null 2>&1
fi
fi

nvm_echo “=> Compressing and cleaning up git repository”
if ! command git --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” reflog expire --expire=now --all; then
nvm_echo >&2 “Your version of git is out of date. Please update it!”
fi
if ! command git --git-dir=“ I N S T A L L D I R " / . g i t − − w o r k − t r e e = " INSTALL_DIR"/.git --work-tree=" INSTALLDIR"/.gitworktree="INSTALL_DIR” gc --auto --aggressive --prune=now ; then
nvm_echo >&2 “Your version of git is out of date. Please update it!”
fi
return
}

Automatically install Node.js

nvm_install_node() {
local NODE_VERSION_LOCAL
NODE_VERSION_LOCAL=“$(nvm_node_version)”

if [ -z “$NODE_VERSION_LOCAL” ]; then
return 0
fi

nvm_echo “=> Installing Node.js version N O D E V E R S I O N L O C A L " n v m i n s t a l l " NODE_VERSION_LOCAL" nvm install " NODEVERSIONLOCAL"nvminstall"NODE_VERSION_LOCAL”
local CURRENT_NVM_NODE

CURRENT_NVM_NODE=" ( n v m v e r s i o n c u r r e n t ) " i f [ " (nvm_version current)" if [ " (nvmversioncurrent)"if["(nvm_version “ N O D E V E R S I O N L O C A L " ) " = = " NODE_VERSION_LOCAL")" == " NODEVERSIONLOCAL")"=="CURRENT_NVM_NODE” ]; then
nvm_echo “=> Node.js version $NODE_VERSION_LOCAL has been successfully installed”
else
nvm_echo >&2 “Failed to install Node.js $NODE_VERSION_LOCAL”
fi
}

install_nvm_as_script() {
local INSTALL_DIR
INSTALL_DIR=“ ( n v m i n s t a l l d i r ) " l o c a l N V M S O U R C E L O C A L N V M S O U R C E L O C A L = " (nvm_install_dir)" local NVM_SOURCE_LOCAL NVM_SOURCE_LOCAL=" (nvminstalldir)"localNVMSOURCELOCALNVMSOURCELOCAL="(nvm_source script)”
local NVM_EXEC_SOURCE
NVM_EXEC_SOURCE=“ ( n v m s o u r c e s c r i p t − n v m − e x e c ) " l o c a l N V M B A S H C O M P L E T I O N S O U R C E N V M B A S H C O M P L E T I O N S O U R C E = " (nvm_source script-nvm-exec)" local NVM_BASH_COMPLETION_SOURCE NVM_BASH_COMPLETION_SOURCE=" (nvmsourcescriptnvmexec)"localNVMBASHCOMPLETIONSOURCENVMBASHCOMPLETIONSOURCE="(nvm_source script-nvm-bash-completion)”

Downloading to $INSTALL_DIR

mkdir -p “ I N S T A L L D I R " i f [ − f " INSTALL_DIR" if [ -f " INSTALLDIR"if[f"INSTALL_DIR/nvm.sh” ]; then
nvm_echo “=> nvm is already installed in I N S T A L L D I R , t r y i n g t o u p d a t e t h e s c r i p t " e l s e n v m e c h o " = > D o w n l o a d i n g n v m a s s c r i p t t o ′ INSTALL_DIR, trying to update the script" else nvm_echo "=> Downloading nvm as script to ' INSTALLDIR,tryingtoupdatethescript"elsenvmecho"=>DownloadingnvmasscripttoINSTALL_DIR’”
fi
nvm_download -s “ N V M S O U R C E L O C A L " − o " NVM_SOURCE_LOCAL" -o " NVMSOURCELOCAL"o"INSTALL_DIR/nvm.sh” || {
nvm_echo >&2 “Failed to download 'KaTeX parse error: Expected 'EOF', got '}' at position 35: … return 1 }̲ & nvm_downlo…NVM_EXEC_SOURCE” -o “KaTeX parse error: Expected '}', got '&' at position 42: … nvm_echo >&̲2 "Failed to do…NVM_EXEC_SOURCE’”
return 2
} &
nvm_download -s “ N V M B A S H C O M P L E T I O N S O U R C E " − o " NVM_BASH_COMPLETION_SOURCE" -o " NVMBASHCOMPLETIONSOURCE"o"INSTALL_DIR/bash_completion” || {
nvm_echo >&2 “Failed to download ‘$NVM_BASH_COMPLETION_SOURCE’”
return 2
} &
for job in ( j o b s − p ∣ c o m m a n d s o r t ) d o w a i t " (jobs -p | command sort) do wait " (jobspcommandsort)dowait"job" || return ? d o n e c h m o d a + x " ? done chmod a+x " ?donechmoda+x"INSTALL_DIR/nvm-exec" || {
nvm_echo >&2 “Failed to mark ‘$INSTALL_DIR/nvm-exec’ as executable”
return 3
}
}

nvm_try_profile() {
if [ -z “ 1 − " ] ∣ ∣ [ ! − f " {1-}" ] || [ ! -f " 1"]∣∣[!f"{1}” ]; then
return 1
fi
nvm_echo “${1}”
}

Detect profile file if not specified as environment variable

(eg: PROFILE=~/.myprofile)

The echo’ed path is guaranteed to be an existing file

Otherwise, an empty string is returned

nvm_detect_profile() {
if [ “${PROFILE-}” = ‘/dev/null’ ]; then
# the user has specifically requested NOT to have nvm touch their profile
return
fi

if [ -n “KaTeX parse error: Expected 'EOF', got '&' at position 14: {PROFILE}" ] &̲& [ -f "{PROFILE}” ]; then
nvm_echo “${PROFILE}”
return
fi

local DETECTED_PROFILE
DETECTED_PROFILE=‘’

if [ “KaTeX parse error: Expected '}', got '#' at position 7: {SHELL#̲*bash}" != "SHELL” ]; then
if [ -f “ H O M E / . b a s h r c " ] ; t h e n D E T E C T E D P R O F I L E = " HOME/.bashrc" ]; then DETECTED_PROFILE=" HOME/.bashrc"];thenDETECTEDPROFILE="HOME/.bashrc”
elif [ -f “ H O M E / . b a s h p r o f i l e " ] ; t h e n D E T E C T E D P R O F I L E = " HOME/.bash_profile" ]; then DETECTED_PROFILE=" HOME/.bashprofile"];thenDETECTEDPROFILE="HOME/.bash_profile”
fi
elif [ “KaTeX parse error: Expected '}', got '#' at position 7: {SHELL#̲*zsh}" != "SHELL” ]; then
if [ -f “ H O M E / . z s h r c " ] ; t h e n D E T E C T E D P R O F I L E = " HOME/.zshrc" ]; then DETECTED_PROFILE=" HOME/.zshrc"];thenDETECTEDPROFILE="HOME/.zshrc”
elif [ -f “ H O M E / . z p r o f i l e " ] ; t h e n D E T E C T E D P R O F I L E = " HOME/.zprofile" ]; then DETECTED_PROFILE=" HOME/.zprofile"];thenDETECTEDPROFILE="HOME/.zprofile”
fi
fi

if [ -z “ D E T E C T E D P R O F I L E " ] ; t h e n f o r E A C H P R O F I L E i n " . p r o f i l e " " . b a s h r c " " . b a s h p r o f i l e " " . z p r o f i l e " " . z s h r c " d o i f D E T E C T E D P R O F I L E = " DETECTED_PROFILE" ]; then for EACH_PROFILE in ".profile" ".bashrc" ".bash_profile" ".zprofile" ".zshrc" do if DETECTED_PROFILE=" DETECTEDPROFILE"];thenforEACHPROFILEin".profile"".bashrc"".bashprofile"".zprofile"".zshrc"doifDETECTEDPROFILE="(nvm_try_profile “ H O M E / {HOME}/ HOME/{EACH_PROFILE}”)”; then
break
fi
done
fi

if [ -n “ D E T E C T E D P R O F I L E " ] ; t h e n n v m e c h o " DETECTED_PROFILE" ]; then nvm_echo " DETECTEDPROFILE"];thennvmecho"DETECTED_PROFILE”
fi
}

Check whether the user has any globally-installed npm modules in their system

Node, and warn them if so.

nvm_check_global_modules() {
local NPM_COMMAND
NPM_COMMAND=“ ( c o m m a n d − v n p m 2 > / d e v / n u l l ) " ∣ ∣ r e t u r n 0 [ − n " (command -v npm 2>/dev/null)" || return 0 [ -n " (commandvnpm2>/dev/null)"∣∣return0[n"{NVM_DIR}” ] && [ -z “KaTeX parse error: Expected '}', got 'EOF' at end of input: {NPM_COMMAND%%"NVM_DIR”/*}" ] && return 0

local NPM_VERSION
NPM_VERSION=“ ( n p m − − v e r s i o n ) " N P M V E R S I O N = " (npm --version)" NPM_VERSION=" (npmversion)"NPMVERSION="{NPM_VERSION:–1}”
[ “${NPM_VERSION%%[!-0-9]*}” -gt 0 ] || return 0

local NPM_GLOBAL_MODULES
NPM_GLOBAL_MODULES=“ ( n p m l i s t − g − − d e p t h = 0 ∣ c o m m a n d s e d − e ′ / n p m @ / d ′ − e ′ / ( e m p t y ) ( npm list -g --depth=0 | command sed -e '/ npm@/d' -e '/ (empty) (npmlistgdepth=0∣commandsede/npm@/de/(empty)/d’
)”

local MODULE_COUNT
MODULE_COUNT=“ ( c o m m a n d p r i n t f ( command printf %s\\n " (commandprintfNPM_GLOBAL_MODULES” |
command sed -ne ‘1!p’ | # Remove the first line
wc -l | command tr -d ’ ’ # Count entries
)"

if [ "KaTeX parse error: Expected 'EOF', got '#' at position 36: …0' ]; then #̲ shellcheck dis…PATH`)’
# shellcheck disable=SC2016
nvm_echo ‘=> override the binaries of modules installed with `nvm`:’
nvm_echo

command printf %s\\n "$NPM_GLOBAL_MODULES"
nvm_echo '=> If you wish to uninstall them at a later point (or re-install them under your'
# shellcheck disable=SC2016
nvm_echo '=> `nvm` Nodes), you can remove them from the system Node as follows:'
nvm_echo
nvm_echo '     $ nvm use system'
nvm_echo '     $ npm uninstall -g a_module'
nvm_echo

fi
}

nvm_do_install() {
if [ -n “KaTeX parse error: Expected 'EOF', got '&' at position 15: {NVM_DIR-}" ] &̲& ! [ -d "{NVM_DIR}” ]; then
if [ -e “KaTeX parse error: Expected 'EOF', got '&' at position 36: … nvm_echo >&̲2 "File \"{NVM_DIR}” has the same name as installation directory."
exit 1
fi

if [ "${NVM_DIR}" = "$(nvm_default_install_dir)" ]; then
  mkdir "${NVM_DIR}"
else
  nvm_echo >&2 "You have \$NVM_DIR set to \"${NVM_DIR}\", but that directory does not exist. Check your profile files and environment."
  exit 1
fi

fi

Disable the optional which check, https://www.shellcheck.net/wiki/SC2230

shellcheck disable=SC2230

if nvm_has xcode-select && [ “$(xcode-select -p >/dev/null 2>/dev/null ; echo KaTeX parse error: Expected 'EOF', got '&' at position 13: ?)" = '2' ] &̲& [ "(which git)” = ‘/usr/bin/git’ ] && [ “KaTeX parse error: Expected 'EOF', got '&' at position 55: … nvm_echo >&̲2 'You may be o…{METHOD}” ]; then
# Autodetect install method
if nvm_has git; then
install_nvm_from_git
elif nvm_has curl || nvm_has wget; then
install_nvm_as_script
else
nvm_echo >&2 ‘You need git, curl, or wget to install nvm’
exit 1
fi
elif [ “KaTeX parse error: Expected 'EOF', got '&' at position 70: … nvm_echo >&̲2 "You need git…{METHOD}” = ‘script’ ]; then
if ! nvm_has curl && ! nvm_has wget; then
nvm_echo >&2 “You need curl or wget to install nvm”
exit 1
fi
install_nvm_as_script
else
nvm_echo >&2 “The environment variable $METHOD is set to “${METHOD}”, which is not recognized as a valid installation method.”
exit 1
fi

nvm_echo

local NVM_PROFILE
NVM_PROFILE=“ ( n v m d e t e c t p r o f i l e ) " l o c a l P R O F I L E I N S T A L L D I R P R O F I L E I N S T A L L D I R = " (nvm_detect_profile)" local PROFILE_INSTALL_DIR PROFILE_INSTALL_DIR=" (nvmdetectprofile)"localPROFILEINSTALLDIRPROFILEINSTALLDIR="(nvm_install_dir | command sed “s:^$HOME:$HOME:”)”

SOURCE_STR=“\nexport NVM_DIR=”${PROFILE_INSTALL_DIR}“\n[ -s “$NVM_DIR/nvm.sh” ] && \. “$NVM_DIR/nvm.sh” # This loads nvm\n”

shellcheck disable=SC2016

COMPLETION_STR=‘[ -s “KaTeX parse error: Expected 'EOF', got '&' at position 28: …_completion" ] &̲& \. "NVM_DIR/bash_completion” # This loads nvm bash_completion\n’
BASH_OR_ZSH=false

if [ -z “ N V M P R O F I L E − " ] ; t h e n l o c a l T R I E D P R O F I L E i f [ − n " {NVM_PROFILE-}" ] ; then local TRIED_PROFILE if [ -n " NVMPROFILE"];thenlocalTRIEDPROFILEif[n"{PROFILE}” ]; then
TRIED_PROFILE=“${NVM_PROFILE} (as defined in $PROFILE), "
fi
nvm_echo “=> Profile not found. Tried T R I E D P R O F I L E −   / . b a s h r c ,   / . b a s h p r o f i l e ,   / . z p r o f i l e ,   / . z s h r c , a n d   / . p r o f i l e . " n v m e c h o " = > C r e a t e o n e o f t h e m a n d r u n t h i s s c r i p t a g a i n " n v m e c h o " O R " n v m e c h o " = > A p p e n d t h e f o l l o w i n g l i n e s t o t h e c o r r e c t f i l e y o u r s e l f : " c o m m a n d p r i n t f " {TRIED_PROFILE-}~/.bashrc, ~/.bash_profile, ~/.zprofile, ~/.zshrc, and ~/.profile." nvm_echo "=> Create one of them and run this script again" nvm_echo " OR" nvm_echo "=> Append the following lines to the correct file yourself:" command printf " TRIEDPROFILE /.bashrc, /.bashprofile, /.zprofile, /.zshrc,and /.profile."nvmecho"=>Createoneofthemandrunthisscriptagain"nvmecho"OR"nvmecho"=>Appendthefollowinglinestothecorrectfileyourself:"commandprintf"{SOURCE_STR}”
nvm_echo
else
if nvm_profile_is_bash_or_zsh “ N V M P R O F I L E − " ; t h e n B A S H O R Z S H = t r u e f i i f ! c o m m a n d g r e p − q c ′ / n v m . s h ′ " {NVM_PROFILE-}"; then BASH_OR_ZSH=true fi if ! command grep -qc '/nvm.sh' " NVMPROFILE";thenBASHORZSH=truefiif!commandgrepqc/nvm.sh"NVM_PROFILE”; then
nvm_echo “=> Appending nvm source string to N V M P R O F I L E " c o m m a n d p r i n t f " NVM_PROFILE" command printf " NVMPROFILE"commandprintf"{SOURCE_STR}” >> “$NVM_PROFILE”
else
nvm_echo “=> nvm source string already in ${NVM_PROFILE}”
fi
# shellcheck disable=SC2016
if KaTeX parse error: Expected 'EOF', got '&' at position 15: {BASH_OR_ZSH} &̲& ! command gre…NVM_DIR/bash_completion’ “$NVM_PROFILE”; then
nvm_echo “=> Appending bash_completion source string to N V M P R O F I L E " c o m m a n d p r i n t f " NVM_PROFILE" command printf " NVMPROFILE"commandprintf"COMPLETION_STR” >> “$NVM_PROFILE”
else
nvm_echo “=> bash_completion source string already in ${NVM_PROFILE}”
fi
fi
if KaTeX parse error: Expected 'EOF', got '&' at position 15: {BASH_OR_ZSH} &̲& [ -z "{NVM_PROFILE-}” ] ; then
nvm_echo “=> Please also append the following lines to the if you are using bash/zsh shell:”
command printf “${COMPLETION_STR}”
fi

Source nvm

shellcheck source=/dev/null

. “$(nvm_install_dir)/nvm.sh”

nvm_check_global_modules

nvm_install_node

nvm_reset

nvm_echo “=> Close and reopen your terminal to start using nvm or run the following to use it now:”
command printf “${SOURCE_STR}”

性能优化

1.webpack打包文件体积过大?(最终打包为一个js文件)

2.如何优化webpack构建的性能

3.移动端的性能优化

4.Vue的SPA 如何优化加载速度

5.移动端300ms延迟

6.页面的重构

所有的知识点都有详细的解答,我整理成了280页PDF《前端校招面试真题精编解析》。

开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值