Error with npm install , NPM安装错误分析

用户尝试使用npm安装Angular2日历组件遇到错误,特别是在Windows环境下安装node-zopfli模块时失败。错误提示涉及预编译二进制文件未找到及Windows SDK版本问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

I wanted to install this angular 2 calendar using npm. Tried to use npm to install it and then downloaded it and tried to install it. In both cases its failed.

I am on windows and I previously got this error trying to install angular2 CLI. Now I am getting the same error for this package and I am not sure how to rectify it. I tried to unistall the CLI and then clear the cache and that didnt work.

Could some one have a look at the error and let me know what steps I need to do to rectify this..

The error as it appears on the cmd is as follows:

 
C:\Users\simon\SPA\ANGULAR2 CALENDAR EXAMPLE>npm install

> node-zopfli@1.4.0 install C:\Users\simon\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.gz
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 source 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\
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\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\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\simon\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64\\zopfli.node" "--module_name=zopfli" "--module_path=C:\\Users\\simon\\node_modules\\node-zopfli\\lib\\binding\\node-v48-win32-x64"
gyp ERR! cwd C:\Users\simon\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\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)
node-pre-gyp ERR! stack at ChildProcess.<anonymous> (C:\Users\simon\node_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\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\simon\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\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64\zopfli.node --module_name=zopfli --module_path=C:\Users\simon\node_modules\node-zopfli\lib\binding\node-v48-win32-x64' (1)


I am on node.js 6.6.0 and npm 3.10.3


I had a similar problem on windows, installing node-gyp globally removed those errors.

# before installing node-gyp on windows
npm install --global --production windows-build-tools

# install node-gyp globally
npm install -g node-gyp


### 解决 `npm install` 错误的方法 #### 权限问题引起的错误处理 当遇到权限不足导致无法安装依赖包的情况时,可以尝试使用管理员权限执行命令。对于Linux或macOS系统,这通常意味着前缀加上`sudo`命令[^2]。 ```bash sudo npm install ``` 然而,在Windows环境下推荐以管理员身份运行命令提示符或者PowerShell来执行同样的操作,而不是简单地增加`sudo`关键字,因为后者并不适用于该操作系统环境。 #### 更改NPM镜像源优化下载速度并规避网络相关失败 为了提高国内用户的下载效率,并降低因网络波动而引发的各种异常状况,建议切换至更稳定的中国区镜像站点——比如淘宝提供的公共镜像服务[^3]: ```bash npm config set registry https://registry.npmmirror.com ``` 此更改会使得后续所有的模块获取请求都指向新的地址,从而可能有效缓解某些特定类型的连接超时等问题。 #### 清除缓存与重置工作空间状态 如果之前的操作未能解决问题,则应当考虑清理本地的npm缓存数据,以及移除已有的`node_modules`文件夹和`package-lock.json`锁定文件后再试一次完整的重新构建流程[^4]: ```bash rm -rf node_modules package-lock.json npm cache clean --force npm install ``` 以上措施有助于排除残留的历史记录干扰因素的影响,确保当前环境中不存在任何潜在冲突项阻碍正常运作。 #### 特殊情况下的深入排查手段 针对更为复杂难解的情形,如持续遭遇EPERM类别的访问控制层面障碍时,除了上述常规调整外还需要进一步确认目标路径下是否存在只读属性或其他形式的安全策略限制;必要情况下甚至可借助专门工具(例如Process Monitor)监控具体行为模式以便精确定位根本原因所在。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值