【翻译WINDOWS NT FILE SYSTEM INTERNAL】NT缓存管理器一(3)

本文介绍了Windows NT中文件流的概念及其实现方式。文件流包括文件数据、目录信息、文件系统元数据等,并探讨了缓存管理器如何通过文件映射来支持文件流缓存。

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

文件流

每个打开文件的实例在windows NT里被表示为一个文件对象结构。任何关联一个文件对象的线性字节流可以被定义为文件流。文件流的例子包括给定文件的数据,一个目录(包含关于文件被存储在磁盘上的信息),文件系统元数据(例如卷信息),与该文件关联的访问控制列表(ACL),和文件一起存储的扩展信息。

NT文件系统创建,删除,操纵文件流,这是以下操作的结果,要么外部生成用户请求去读或者写文件数据,或者内部生成请求去操纵文件系统描述数据结构。文件系统识别他们希望支持和缓存的文件流。例如,除非由用户另作说明,文件系统缓存用户数据被包含在一个文件里。对于每一个被缓存的文件流,文件系统支持缓存访问和非缓存访问。

缓存管理器使用文件映射来支持文件流缓存,文件映射把缓存和内存管理器对于分页内存的策略结合起来(and it also integrates caching with the memory manager'spolicies for other uses of pageable memory)。处于对缓存管理器的期望,流是表示多少字节信息将被保持在内存中的一个随机字节数。因此,缓存管理器提供的相同服务集可以被文件系统驱动用来缓存文件数据或者文件系统元数据。

npm ERR! code 1 npm ERR! path D:\work\opscloud4\opscloud4-web-master\node_modules\deasync npm ERR! command failed npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node ./build.js npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@10.0.1 npm ERR! gyp info using node@18.19.0 | win32 | x64 npm ERR! gyp info find Python using Python version 3.12.3 found at "C:\Users\27145\AppData\Local\Programs\Python\Python312\python.exe" npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS msvs_version not set from command line or npm config npm ERR! gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt npm ERR! gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer, try re-running with '--loglevel silly' for more details npm ERR! gyp ERR! find VS looking for Visual Studio 2015 npm ERR! gyp ERR! find VS - not found npm ERR! gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8 npm ERR! gyp ERR! find VS npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS You need to install the latest version of Visual Studio npm ERR! gyp ERR! find VS including the "Desktop development with C++" workload. npm ERR! gyp ERR! find VS For more information consult the documentation at: npm ERR! gyp ERR! find VS https://github.com/nodejs/node-gyp#on-windows npm ERR! gyp ERR! find VS ************************************************************** npm ERR! gyp ERR! find VS npm ERR! gyp ERR! configure error npm ERR! gyp ERR! stack Error: Could not find any Visual Studio installation to use npm ERR! gyp ERR! stack at VisualStudioFinder.fail (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:113:11) npm ERR! gyp ERR! stack at VisualStudioFinder.findVisualStudio (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:69:17) npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5) npm ERR! gyp ERR! stack at async createBuildDir (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\lib\configure.js:69:26) npm ERR! gyp ERR! stack at async run (D:\ProgramFile\developTool\nvm\nvm\v18.19.0\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js:81:18) npm ERR! gyp ERR! System Windows_NT 10.0.26100 npm ERR! gyp ERR! command "D:\\ProgramFile\\developTool\\nvm_nodejs\\nodejs\\node.exe" "D:\\ProgramFile\\developTool\\nvm\\nvm\\v18.19.0\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd D:\work\opscloud4\opscloud4-web-master\node_modules\deasync npm ERR! gyp ERR! node -v v18.19.0 npm ERR! gyp ERR! node-gyp -v v10.0.1 npm ERR! gyp ERR! not ok npm ERR! Build failed
06-10
<think>我们正在处理Windows10系统上安装`deasync`模块时出现的node-gyp配置错误。用户已经提供了node版本(v18.19.0)和node-gyp版本(v10.0.1),并指出错误是关于找不到VisualStudio(gypERRfindVS)。根据经验,这个错误通常是因为缺少编译所需的构建工具(在Windows上是VisualC++BuildTools)或者Python环境配置问题。虽然用户的问题中提到了VisualStudio,但注意node-gyp在Windows上需要的是构建工具,不定是完整的VisualStudio。同时,参考用户提供的引用内容,我们可以发现:-引用[1]提到node版本问题,但用户已经降级到18.19.0,这是LTS版本,应该没问题。-引用[2]提到了权限问题,但Windows上的权限错误通常表现为访问拒绝,用户的问题描述是找不到VS,所以暂时排除。-引用[3]提到了使用`--legacy-peer-deps`解决依赖冲突,但用户的问题是关于编译工具缺失,不是依赖冲突。因此,我们将重点放在解决Windows上构建工具的安装和配置上。###解决方案步骤:####1.安装构建工具在Windows上,node-gyp需要安装VisualStudioBuildTools,特别是其中的C++工具集。推荐安装方法:-使用Microsoft提供的`windows-build-tools`包(已不再维护,但对于老版本node-gyp可能有效)或者直接安装VisualStudioBuildTools2019或2022。但是,更推荐直接安装VisualStudio2022并选择“使用C++的桌面开发”工作负载,注意勾选:-MSVCv143-VS2022C++x64/x86生成工具(最新)-Windows10SDK(或最新版本)-如果没有安装Python,也需要安装Python,但node-gyp通常会使用自带的Python,不过有时需要指定。由于用户已经安装了node-gypv10.0.1,它可能要求Python版本(需要Python2.7或3.x),但注意最新版本的node-gyp支持Python3。在Windows上,如果没有安装Python,也会报错。####2.使用npm配置设置如果已经安装了构建工具,但仍然报错,可能是因为node-gyp没有找到安装路径。我们可以通过npm配置设置MSVS的版本。####3.通过命令行安装构建工具(可选)也可以尝试通过命令安装构建工具(需要管理员权限的PowerShell):```powershellnpminstall--globalwindows-build-tools```但注意这个包可能已经过时,而且安装过程可能很慢。####4.如果上述步骤无效,尝试手动设置环境变量###具体操作步骤:**步骤1:安装VisualStudioBuildTools2022**1.下载安装程序:访问[VisualStudio下载页面](https://visualstudio.microsoft.com/zh-hans/downloads/),下载“BuildToolsforVisualStudio2022”。2.运行安装程序,选择“使用C++的桌面开发”工作负载,并确保勾选了Windows10SDK(或11)和MSVCv143生成工具。3.安装完成后,重启电脑。**步骤2:设置npm配置(可选)**在终端中运行以下命令,指定使用的VisualStudio版本:```bashnpmconfigsetmsvs_version2022```**步骤3:检查Python环境**虽然node-gypv10支持Python3,但是确保系统有可用的Python环境(建议Python3.7以上),并且将其添加到环境变量。可以通过命令检查:```bashpython--version```如果没有,则安装Python并确保勾选“添加到PATH”。然后设置npm的Python路径(如果Python在非标准位置):```bashnpmconfigsetpython<path_to_python_executable>```**步骤4:重试安装deasync**在安装命令前添加`--global`选项以获取可能的更详细日志,或者使用:```bashnpminstalldeasync--save```如果之前失败,可能需要先删除`node_modules`再重试。**步骤5:如果遇到权限问题**尝试使用管理员权限打开终端(命令提示符或PowerShell)。###错误处理:如果仍然出现错误,请检查错误日志,常见的解决方向:1.确认构建工具安装正确:打开“VisualStudioInstaller”,确认已安装的构建工具。2.检查环境变量:确保VS的路径在环境变量中(安装后通常会自动添加)。3.更新node-gyp:虽然用户使用的是node-gypv10.0.1,但可以尝试更新到最新版本(注意,node附带的node-gyp版本是固定的,可以通过`npminstall-gnode-gyp`升级,但可能和node不兼容,所以通常不建议)。###补充说明:根据官方文档,Node.js18需要VS2019或VS2022,所以步骤1中安装VS2022构建工具应该可以解决问题。###相关命令总结```powershell#安装构建工具后设置msvs_versionnpmconfigsetmsvs_version2022#设置python路径(如果需要)npmconfigsetpython"C:\Python39\python.exe"#清除npm缓存后重新安装npmcacheclean--forcenpminstalldeasync```###相关问题§§相关问题§§1.如何在Windows上配置Node.js原生模块编译环境?2.使用npm安装依赖时遇到权限被拒绝(EACCES)错误如何解决?3.如何升级或降级node-gyp以兼容不同的Node.js版本?</think> ### 解决 Windows 10 上安装 deasync 模块的 node-gyp 配置错误 #### 根本原因分析 在 Windows 10 使用 Node.js v18.19.0 安装 `deasync` 时出现 `gyp ERR find VS` 错误,通常是由于: 1. **缺失编译工具链**:deasync 包含原生 C++ 代码,需要 Visual Studio 构建工具编译 2. **未配置系统环境**:node-gyp v10.0.1 需要明确识别 Visual Studio 路径 3. **权限问题**:系统可能阻止创建构建目录(参考[^2]) #### 解决方案(分步操作) ##### 1. 安装必备构建工具 安装 **Microsoft Visual C++ 构建工具**(非完整VS): ```powershell # 使用管理员权限运行 PowerShell npm install --global windows-build-tools ``` » 该命令自动安装: - Python 2.7(node-gyp 兼容所需) - Visual C++ Build Tools 2022 - Windows SDK ##### 2. 配置系统环境变量 ```powershell # 设置 node-gyp 的 VS 版本标识 npm config set msvs_version 2022 # 验证配置 npm config list | Select-String "msvs" ``` » 应显示: `msvs_version = 2022` ##### 3. 修复权限问题(参考[^2]) ```powershell # 授予当前用户完全控制权限 icacls "C:\Program Files\nodejs" /grant "$env:USERNAME:(OI)(CI)F" # 清理缓存后重试 npm cache clean --force ``` ##### 4. 安全安装 deasync ```powershell npm install deasync --save --legacy-peer-deps ``` » `--legacy-peer-deps` 规避依赖冲突(参考[^3]) #### 验证安装 ```javascript // test.js const deasync = require(&#39;deasync&#39;); console.log("Deasync 加载成功!"); ``` 运行:`node test.js` » 应输出成功消息 #### 备用方案 若仍失败,**推荐使用 Docker 容器编译**: ```dockerfile FROM node:18.19.0-windowsservercore RUN npm install --global windows-build-tools WORKDIR /app COPY package.json . RUN npm install --legacy-peer-deps ``` ### 故障排查矩阵 | 错误现象 | 解决方案 | 验证命令 | |----------|----------|----------| | `gyp ERR! find VS` | 重装 windows-build-tools | `npm ls -g windows-build-tools` | | `EACCES: permission denied` | 执行权限授予步骤 | `icacls "C:\Program Files\nodejs"` | | `ERR! stack Error: Could not find any Python` | 检查 Python 2.7 路径 | `where python` | ### 相关问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值