node.js - 全局安装 Angular cli 时出错
问题描述
我是这个平台的新手。我正在使用 IntelliJ Idea Ultimate 版本。我安装了 node js 版本 v10.14.2。
我尝试使用 npm install -g @angular/cli
收到以下错误的命令。
npm ERR! path C:\Users\D\AppData\Roaming\npm\ng.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete C:\Users\D\AppData\Roaming\npm\ng.cmd: node_modules\angular-cli\bin\ng symlink target is not controlled by npm C:\Users\D\AppData\Roaming\npm\node_modules\@angular\cli
npm ERR! File exists: C:\Users\D\AppData\Roaming\npm\ng.cmd
npm ERR! Move it away, and try again.
我不确定这里有什么问题。任何线索都会非常有帮助。
尝试安装后,出现以下错误
npm WARN deprecated angular-cli@1.0.0-beta.28.3: angular-cli has been renamed to @angular/cli. Please update your dependencies.
npm WARN deprecated exists-sync@0.0.3: Please replace with usage of fs.existsSync
npm WARN deprecated browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated boom@2.10.1: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated cryptiles@2.0.5: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated hoek@2.16.3: This version is no longer maintained. Please upgrade to the latest version.
npm WARN deprecated gulp-util@3.0.7: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
C:\Users\D\AppData\Roaming\npm\ng -> C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\bin\ng
> node-sass@4.11.0 install C:\Users\DRAJKUM3\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-64_binding.node":
tunneling socket could not be established, cause=getaddrinfo ENOTFOUND f.com f.com:8080
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
> node-sass@4.11.0 postinstall C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-sass
> node scripts/build.js
Building: C:\Program Files\nodejs\node.exe C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'C:\\Users\\D\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp@3.8.0
gyp info using node@10.14.2 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Users\DRAJKUM3\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:154:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2\n at getNotFoundError (C:\\Users\\D\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\which\\which.js:13:12)\n at F (C:\\Users\\DRAJKUM3\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\which\\which.js:68:19)\n at E (C:\\Users\\DRAJKUM3\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\which\\which.js:80:29)\n at C:\\Users\\DRAJKUM3\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\which\\which.js:89:16\n at C:\\Users\\DRAJKUM3\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\isexe\\index.js:42:5\n at C:\\Users\\DRAJKUM3\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplete (fs.js:154:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\D\AppData\Local\Programs\Python\Python37-32\python.EXE
gyp ERR! configure error
gyp ERR! stack Error: Command failed: C:\Users\D\AppData\Local\Programs\Python\Python37-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at maybeClose (internal/child_process.js:962:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\D\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd C:\Users\D\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-sass
gyp ERR! node -v v10.14.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN @angular/core@2.4.10 requires a peer of rxjs@^5.0.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\angular-cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.11.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
我已经安装了 PYTHON 并将其设置为环境变量。我也为 GIT 做了同样的事情。
EDIT2 构建过程出错
The projects in this solution are created one after the other. To enable a parallel creation, you must add the "/ m" switch.
The build process was started on 02.01.2019 14:34:39.
Project "C: \ Users \ D \ IdeaProjects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln" on node "1" (default destinations).
ValidateSolutionConfiguration:
The solution configuration "Release | x64" is created.
MSBUILD: error MSB3428: Could not load Visual C ++ component VCBuild.exe. To fix this problem, install either 1) the .NET Framework 2.0 SDK or 2) Microsoft Visual Studio 2005 or 3) add the location of the component m Add system path if it is different from the default location. [C: \ Users \ D \ Idea Projects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln]
Creation of the project "C: \ Users \ D \ IdeaProjects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln" is complete (default targets) - ERROR.
Error during the build process.
The projects in this solution are created one after the other. To enable a parallel creation, you must add the "/ m" switch.
The build process was started on 02.01.2019 14:34:39.
Project "C: \ Users \ D \ IdeaProjects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln" on node "1" (default destinations).
ValidateSolutionConfiguration:
The solution configuration "Release | x64" is created.
MSBUILD: error MSB3428: Could not load Visual C ++ component VCBuild.exe. To fix this problem, install either 1) the .NET Framework 2.0 SDK or 2) Microsoft Visual Studio 2005 or 3) add the location of the component
m Add system path if it is different from the default location. [C: \ Users \ D \ Idea Projects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln]
Creation of the project "C: \ Users \ D \ IdeaProjects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln" is complete (default targets) - ERROR.
Error during the build process.
"C: \ Users \ D \ IdeaProjects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln" (default destination) (1) ->
(_src_ \ libsass destination) ->
MSBUILD: error MSB3428: Could not load Visual C ++ component VCBuild.exe. To fix this problem, install either 1) .NET Framework 2.0 SDK or 2) Microsoft Visual Studio 2005 or 3) add the location of the component
to the system path if it differs from the default location. [C: \ Users \ D \ Idea Projects \ AngularHelloWorld \ helloworld \ node_modules \ node-sass \ build \ binding.sln]
解决方案
好像您正在使用 Python 3.x
...
Error: Command failed: C:\Users\D\AppData\Local\Programs\Python\Python37-32\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
...
node-gyp
文档说不支持
Python 3.x https://github.com/nodejs/node-gyp
尝试完全卸载 Python 并安装 v2.7
升级版:
为什么你甚至需要node-gyp
?如果你看线条
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-64_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-64_binding.node":
您会看到您的安装尝试为node-sass
您的环境下载预构建版本但失败。之后,该程序将下载node-sass
源代码并临时构建它们。此步骤需要node-gyp
安装并准备好使用。
推荐阅读
- mysql - MYSQL - Advice on populating FIELD options from another TABLE COLUMN using ENUM
- amazon-web-services - 使用 FFmpeg 从受保护的 m3u8 直播流中获取屏幕截图
- flutter - 从静态区域获取 ThemeData
- c# - asp.net core: What is the best practice to execute code in a container application for kubernetes
- javascript - React Component from AJAX call
- xml - 如何使用 scala 从数据框创建 XML 字符串
- swift - XCTest 异步函数 Swift
- c# - how to only transform.position the x position and not also the y c# unity
- sql - Update remaining amount on a debit card with MS Access / SQL according to card number
- c++ - 将定义的类声明为模板参数内的结构