2016-09-25 52 views
0

建議我運行「npm install -g angular-cli」來安裝CLI工具。嘗試安裝Angular-cli工具時遇到錯誤

我已經使用「npm install --global --production windows-build-tools」以及「npm install -g node-gyp」通過以管理員身份運行的powershell安裝了windows工具。

我仍然無法得到這個工作...我知道Python 2.7已安裝和Gyp,因爲我已經安裝了其他項目,但這一個失敗。

的錯誤如下:

PS C:\WINDOWS\system32> npm install -g angular-cli 
npm WARN deprecated [email protected]: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update t 
o [email protected]^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree. 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: This package is discontinued. Use [email protected]^4.0.0. 
npm WARN deprecated [email protected]: This package is deprecated. Use Object.assign. 
npm WARN deprecated [email protected]: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue 
npm WARN deprecated [email protected]: 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 

> [email protected] 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 [email protected] and [email protected] (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:[email protected] [email protected] install: `node-pre-gyp install --fallback-to-build` 
npm WARN install:[email protected] Exit status 1 
C:\Users\simon\AppData\Roaming\npm 
`-- [email protected] 

npm WARN optional Skipping failed optional dependency /angular-cli/chokidar/fsevents: 
npm WARN notsup Not compatible with your operating system or architecture: [email protected] 

我注意到,fsevents失敗(NPM WARN在底部)...但它說,它的一個可選的依賴。

我曾參觀過這裏,我unistalled CLI其他問題/清除緩存,然後reistalled最新...

這樣做,然後重新啓動我第一次嘗試納克--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工具來工作?

+0

你更新你的節點+ NPM安裝?或者您的機器中當前的node-gyp與您當前的節點安裝不兼容 –

+0

正在運行的節點6.6.0和npm 3.10.3 ..我不確定節點6.6.0的情況是否可用等。我只是不知道...但是我會認爲開發CLI工具的人會包括最新的,因爲他們仍然要最終確定並且會使用新的工具等。 – si2030

+0

我有同樣的麻煩,但必須將node-gyp備份到版本2.7因爲^ 3不被支持。檢查你已安裝的版本。 –

回答

0

我已經通過安裝較低版本解決了類似問題。

首先,你應該使用

npm uninstall -g angular-cli 
npm cache clean 

清潔之後將其卸載乾淨緩存,嘗試安裝低版本。

例如。像「npm install -g [email protected]」(即現在的版本是0.24)

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

0

好,

它看起來就像是對角CLI版本你是一個錯configuragion文件使用。

在角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" 
    }