确保以管理员权限运行 Visual Studio 开发者命令提示符
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.12.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools>node-gyp configure --msvs_version=2022
gyp info it worked if it ends with ok
gyp info using node-gyp@10.2.0
gyp info using node@16.13.2 | win32 | x64
gyp info find Python using Python version 3.12.6 found at "D:\Python312\python.exe"
gyp ERR! configure error
gyp ERR! stack Error: EPERM: operation not permitted, mkdir 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\build'
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "D:\\Java\\node-v16.13.2-win-x64\\node-v16.13.2-win-x64\\node.exe" "F:\\my_java\\mynpm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--msvs_version=2022"
gyp ERR! cwd C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
gyp ERR! node -v v16.13.2
gyp ERR! node-gyp -v v10.2.0
gyp ERR! not ok
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools>
这个错误提示表明,node-gyp
在执行时遇到权限问题,无法在 C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
目录下创建 build
目录。这通常是由于权限不足造成的,因为 Program Files
是系统保护目录,普通用户需要更高的权限才能对其进行操作。
解决方法:
1. 以管理员身份运行命令提示符
- 确保以管理员权限运行 Visual Studio 开发者命令提示符。
- 右键点击 Visual Studio Developer Command Prompt,选择 以管理员身份运行。
- 在管理员模式下,再次执行
node-gyp configure
命令:node-gyp configure --msvs_version=2022
2. 改变目录权限
如果不想每次都以管理员身份运行,你可以尝试为 C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
目录授予写入权限。
- 右键点击
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools
文件夹,选择 属性。 - 转到 安全 标签,点击 编辑。
- 为当前用户或
Administrators
组赋予 完全控制 权限。 - 确认并保存更改后,重新运行命令。
3. 改变项目目录位置
由于该目录位于系统的保护区域(Program Files
),建议将项目移动到其他非系统保护目录(如 C:\Users\dgq\
)并在那里运行 node-gyp
命令。这样做可以避免系统权限问题。
- 将你的项目文件夹移到例如
C:\Users\dgq\Downloads\spid-admin
这样的非系统目录。 - 然后在新的目录中运行
node-gyp
:node-gyp configure --msvs_version=2022
4. 检查文件系统权限
如果以上方法仍然无效,可以尝试检查文件系统的权限问题,确保没有文件夹锁定或者其他应用(如防病毒软件)阻止了 node-gyp
的正常执行。
总结:
- 尝试以管理员身份运行命令提示符。
- 如果不想每次都以管理员身份运行,可以修改目录权限。
- 可以将项目移到非系统保护目录,避免权限问题。
**********************************************************************
** Visual Studio 2022 Developer Command Prompt v17.12.0
** Copyright (c) 2022 Microsoft Corporation
**********************************************************************
C:\Windows\System32>node-gyp configure --msvs_version=2022
gyp info it worked if it ends with ok
gyp info using node-gyp@10.2.0
gyp info using node@16.13.2 | win32 | x64
gyp info find Python using Python version 3.12.6 found at "D:\Python312\python.exe"
gyp info find VS using VS2022 (17.12.0) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn D:\Python312\python.exe
gyp info spawn args [
gyp info spawn args 'F:\\my_java\\mynpm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Windows\\System32\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'F:\\my_java\\mynpm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\dgq\\AppData\\Local\\node-gyp\\Cache\\16.13.2\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\dgq\\AppData\\Local\\node-gyp\\Cache\\16.13.2',
gyp info spawn args '-Dnode_gyp_dir=F:\\my_java\\mynpm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\dgq\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.13.2\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\Windows\\System32',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\Windows\\System32\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp: binding.gyp not found (cwd: C:\Windows\System32) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.<anonymous> (F:\my_java\mynpm\node_modules\node-gyp\lib\configure.js:317:18)
gyp ERR! stack at ChildProcess.emit (node:events:390:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "D:\\Java\\node-v16.13.2-win-x64\\node-v16.13.2-win-x64\\node.exe" "F:\\my_java\\mynpm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--msvs_version=2022"
gyp ERR! cwd C:\Windows\System32
gyp ERR! node -v v16.13.2
gyp ERR! node-gyp -v v10.2.0
gyp ERR! not ok
C:\Windows\System32>
C:\Windows\System32>cd C:\Users\dgq\Downloads\spid-admin\spid-admin
C:\Users\dgq\Downloads\spid-admin\spid-admin>node-gyp configure --msvs_version=2022
gyp info it worked if it ends with ok
gyp info using node-gyp@10.2.0
gyp info using node@16.13.2 | win32 | x64
gyp info find Python using Python version 3.12.6 found at "D:\Python312\python.exe"
gyp info find VS using VS2022 (17.12.0) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn D:\Python312\python.exe
gyp info spawn args [
gyp info spawn args 'F:\\my_java\\mynpm\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\dgq\\Downloads\\spid-admin\\spid-admin\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'F:\\my_java\\mynpm\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\dgq\\AppData\\Local\\node-gyp\\Cache\\16.13.2\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\dgq\\AppData\\Local\\node-gyp\\Cache\\16.13.2',
gyp info spawn args '-Dnode_gyp_dir=F:\\my_java\\mynpm\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\dgq\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\16.13.2\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=C:\\Users\\dgq\\Downloads\\spid-admin\\spid-admin',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'C:\\Users\\dgq\\Downloads\\spid-admin\\spid-admin\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
gyp: binding.gyp not found (cwd: C:\Users\dgq\Downloads\spid-admin\spid-admin) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.<anonymous> (F:\my_java\mynpm\node_modules\node-gyp\lib\configure.js:317:18)
gyp ERR! stack at ChildProcess.emit (node:events:390:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Windows_NT 10.0.19045
gyp ERR! command "D:\\Java\\node-v16.13.2-win-x64\\node-v16.13.2-win-x64\\node.exe" "F:\\my_java\\mynpm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure" "--msvs_version=2022"
gyp ERR! cwd C:\Users\dgq\Downloads\spid-admin\spid-admin
gyp ERR! node -v v16.13.2
gyp ERR! node-gyp -v v10.2.0
gyp ERR! not ok
C:\Users\dgq\Downloads\spid-admin\spid-admin>
原文地址:https://blog.csdn.net/m0_65152767/article/details/143783679
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!