尝试安装Angular-cli工具时出错

时间:2016-09-25 04:14:27

标签: node.js angular npm

建议我运行“npm install -g angular-cli”来安装CLI工具。

我已经使用“npm install --global --production windows-build-tools”以及“npm install -g node-gyp”安装了windows工具,这些工具都是以管理员身份运行的powershell。

我仍然无法让这个工作......我知道Python 2.7已经安装并且我已经安装了其他项目,但是这个项目失败了。

错误如下:

    PS C:\WINDOWS\system32> npm install -g angular-cli
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update t
o graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated lodash-node@2.4.1: This package is discontinued. Use lodash@^4.0.0.
npm WARN deprecated lodash.assign@4.2.0: This package is deprecated. Use Object.assign.
npm WARN deprecated minimatch@0.3.0: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated tough-cookie@2.2.2: ReDoS vulnerability parsing Set-Cookie https://nodesecurity.io/advisories/130
C:\Users\simon\AppData\Roaming\npm\ng -> C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\bin\ng

> node-zopfli@1.4.0 install C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-zopfli
> node-pre-gyp install --fallback-to-build

node-pre-gyp ERR! Tried to download: https://node-zopfli.s3.amazonaws.com/Release/zopfli-v1.4.0-node-v48-win32-x64.tar.g
z
node-pre-gyp ERR! Pre-built binaries not found for node-zopfli@1.4.0 and node@6.6.0 (node-v48 ABI) (falling back to sour
ce compile with node-gyp)
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Platforms\x64\PlatformToolsets\v140\Toolset.targets(36,5): error
 MSB8036: The Windows SDK version 8.1 was not found. Install the required version of Windows SDK or change the SDK vers
ion in the project property pages or by right-clicking the solution and selecting "Retarget solution". [C:\Users\simon\
AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-zopfli\build\zopfli.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node
-gyp\lib\build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:106:13)
gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Windows_NT 10.0.14393
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\simon\\AppData\\Roaming\\npm\\node_modules\\angular-c
li\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\simon\\AppData\\Roaming
\\npm\\node_modules\\angular-cli\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64\\zopfli.node" "--module_na
me=zopfli" "--module_path=C:\\Users\\simon\\AppData\\Roaming\\npm\\node_modules\\angular-cli\\node_modules\\node-zopfli\
\lib\\binding\\node-v48-win32-x64"
gyp ERR! cwd C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-zopfli
gyp ERR! node -v v6.6.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\simon\AppData\Roaming\npm\no
de_modules\angular-cli\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\AppData\R
oaming\npm\node_modules\angular-cli\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zo
pfli --module_path=C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-zopfli\lib\binding\node
-v48-win32-x64' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\nod
e_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:106:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:191:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:877:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
node-pre-gyp ERR! System Windows_NT 10.0.14393
node-pre-gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\simon\\AppData\\Roaming\\npm\\node_modules\\
angular-cli\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-zopfli
node-pre-gyp ERR! node -v v6.6.0
node-pre-gyp ERR! node-pre-gyp -v v0.6.30
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_mod
ules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\AppData\Roaming\npm\node_modules\angular
-cli\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\sim
on\AppData\Roaming\npm\node_modules\angular-cli\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)
npm WARN install:node-zopfli@1.4.0 node-zopfli@1.4.0 install: `node-pre-gyp install --fallback-to-build`
npm WARN install:node-zopfli@1.4.0 Exit status 1
C:\Users\simon\AppData\Roaming\npm
`-- angular-cli@1.0.0-beta.15

npm WARN optional Skipping failed optional dependency /angular-cli/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.14

我注意到fsevents失败了(npm WARN在底部)......但它说它是一个可选的依赖。

我已经访问了其他问题,我没有阻止cli /清除缓存,然后重新安装最新的...

执行此操作然后重新启动PC后,我首先尝试了--help并获得了:

    C:\Users\simon\SPA\CLI-MASTER\Test>ng --help
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

TypeError: path must be a string or Buffer
    at TypeError (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Function.Version.fromProject (C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\upgrade\version.js:87:31)
    at Function.Version.isPreWebpack (C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\upgrade\version.js:111:31)
    at Function.Version.assertPostWebpackVersion (C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\upgrade\version.js:97:18)
    at C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\bin\ng:25:15
    at C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\resolve\lib\async.js:44:21
    at ondir (C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\resolve\lib\async.js:187:31)
    at C:\Users\simon\AppData\Roaming\npm\node_modules\angular-cli\node_modules\resolve\lib\async.js:153:39

不是我希望的......

如何解决此问题并使CLI工具正常工作?

2 个答案:

答案 0 :(得分:0)

我通过安装较低版本解决了类似的问题。

首先,您应该使用

卸载它并清理缓存
npm uninstall -g angular-cli
npm cache clean

清洁后,请尝试安装较低版本。

e.g。比如“npm install -g angular-cli@1.0.0-beta.20”。(现在的版本是.24)

我的包的版本是:node v6.92 ,npm 3.10.9 ,tsc v2.1.4

答案 1 :(得分:0)

好吧,

对于您正在使用的angular-cli版本,它看起来是一个错误的configuragion文件。

在angular-cli.json文件中,尝试更改以下内容:

来自:

  "environmentSource": "environments/environment.ts",
  "environments": {
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
  }

到:

  "environments": {
    "source": "environments/environment.ts",
    "dev": "environments/environment.ts",
    "prod": "environments/environment.prod.ts"
  }