在 Linux 虚拟机中安装 Angular 时 tar.unpack 解压错误

在 Linux 虚拟机中安装 Angular 时 tar.unpack 解压错误

我正在使用来自的命令Angular进行安装,出现以下错误Linux VM (3.10.0.1062)npm install @angular/[email protected]Putty terminal

[host@machinename /]$  npm install @angular/[email protected]
npm WARN engine @angular/[email protected]: wanted: {"node":">= 10.13.0","npm":">= 6.11.0","yarn":">= 1.13.0"} (current: {"node":"0.12.18","npm":"2.15.11"})
npm ERR! tar.unpack untar error /home/usermachine/.npm/@angular/cli/10.0.5/package.tgz
npm ERR! Linux 3.10.0-1062.9.1.el7.x86_64
npm ERR! argv "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/node" "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/npm" "install" "@angular/[email protected]"
npm ERR! node v0.12.18
npm ERR! npm  v2.15.11
npm ERR! path /node_modules
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, mkdir '/node_modules'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, mkdir '/node_modules']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/node_modules',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/node_modules/@angular/cli',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack:
npm ERR!    [ '/usr/local/lib/nodejs/node-v0.12.18-linux-x64/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:25',
npm ERR!      '/usr/local/lib/nodejs/node-v0.12.18-linux-x64/lib/node_modules/npm/node_modules/mkdirp/index.js:35:29',
npm ERR!      '/usr/local/lib/nodejs/node-v0.12.18-linux-x64/lib/node_modules/npm/node_modules/mkdirp/index.js:47:53',
npm ERR!      'FSReqWrap.oncomplete (fs.js:95:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! Linux 3.10.0-1062.9.1.el7.x86_64
npm ERR! argv "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/node" "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/npm" "install" "@angular/[email protected]"
npm ERR! node v0.12.18
npm ERR! npm  v2.15.11
npm ERR! path npm-debug.log.1371631876
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, open 'npm-debug.log.1371631876'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES, open 'npm-debug.log.1371631876'] errno: -13, code: 'EACCES', path: 'npm-debug.log.1371631876' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log

这是我的机器上的可用空间

在此输入图像描述

如果我这样做,就会出现以下错误sudo npm install @angular/[email protected]

[host@machinename /]$ sudo npm install @angular/[email protected]
npm ERR! Linux 3.10.0-1062.9.1.el7.x86_64
npm ERR! argv "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/node" "/usr/local/lib/nodejs/node-v0.12.18-linux-x64/bin/npm" "install" "@angular/[email protected]"
npm ERR! node v0.12.18
npm ERR! npm  v2.15.11
npm ERR! code ETIMEDOUT
npm ERR! errno ETIMEDOUT
npm ERR! syscall connect

npm ERR! network connect ETIMEDOUT
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly.  See: 'npm help config'

npm ERR! Please include the following file with any support request:
npm ERR!     /npm-debug.log

我该如何修复这个错误?

相关内容