【问题标题】:Cannot build an NPM package无法构建 NPM 包
【发布时间】:2022-01-31 04:47:28
【问题描述】:

我正在尝试使用名为 nodegit 的库。 当我尝试按如下方式安装它时:

yarn add nodegit

我收到以下提示:

error C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit: Command failed.
Exit code: 1                                                                                
Command: node lifecycleScripts/preinstall && node lifecycleScripts/install
Arguments:
Directory: C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit
Output:
[nodegit] Running pre-install script
[nodegit] Running install script
node-pre-gyp
info it worked if it ends with ok
node-pre-gyp info using
node-pre-gyp@0.13.0
node-pre-gyp info using node@16.13.1 | win32 | x64
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp info check checked for "C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\Release\nodegit.node" (not found)
node-pre-gyp http GET https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
node-pre-gyp http 404 https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
node-pre-gyp WARN Tried to download(404): https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
node-pre-gyp WARN
Pre-built binaries not found for nodegit@0.27.0 and node@16.13.1 (node-v93 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp http 404 status code downloading tarball https://axonodegit.s3.amazonaws.com/nodegit/nodegit/nodegit-v0.27.0-node-v93-win32-x64.tar.gz
gyp

info it worked if it ends with ok
gyp info using
node-gyp@4.0.0
gyp info using node@16.13.1 | win32 | x64
gyp info ok
gyp
info
it worked if it ends with ok
gyp info
using
node-gyp@4.0.0
gyp info
using node@16.13.1 | win32 | x64
(node:32484) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
(Use `node --trace-deprecation ...` to show where the warning was created)
gyp
info spawn C:\Users\ibrahim.koz\.windows-build-tools\python27\python.exe
gyp info spawn args [
gyp info spawn args   'C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\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   '-G',
gyp info spawn args   'msvs_version=2015',
gyp info
spawn args   '-I',
gyp info spawn args   'C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\nodegit\\build\\config.gypi',
gyp info
spawn args   '-I',
gyp info
spawn args   'C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   'C:\\Users\\ibrahim.koz\\.node-gyp\\16.13.1\\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\\ibrahim.koz\\.node-gyp\\16.13.1',
gyp info spawn args   '-Dnode_gyp_dir=C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\node-gyp',
gyp info spawn args   '-Dnode_lib_file=C:\\Users\\ibrahim.koz\\.node-gyp\\16.13.1\\<(target_arch)\\node.lib',
gyp info spawn args   '-Dmodule_root_dir=C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\nodegit',
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\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\nodegit\\build',
gyp info spawn args   '-Goutput_dir=.'
gyp
info spawn args ]
gyp info ok
gyp

info it worked if it ends with ok
gyp
info
using
node-gyp@4.0.0
gyp info using node@16.13.1 | win32 | x64
gyp info
spawn C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
gyp
info spawn args [
gyp info spawn args   'build/binding.sln',
gyp
info spawn args   '/clp:Verbosity=minimal',
gyp info spawn args   '/nologo',
gyp info
spawn args   '/p:Configuration=Release;Platform=x64'
gyp info spawn args ]
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\acquireOpenSSL.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the 
path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\configureLibssh2.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that th
e path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\vendor\http_parser\http_parser.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. C
onfirm that the path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\vendor\libgit2.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the 
path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\vendor\libssh2.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the 
path in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\vendor\pcre.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the pat
h in the <Import> declaration is correct, and that the file exists on disk.
C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\vendor\zlib.vcxproj(20,3): error MSB4019: The imported project "C:\Microsoft.Cpp.Default.props" was not found. Confirm that the pat
h in the <Import> declaration is correct, and that the file exists on disk.
gyp ERR! build error
gyp ERR!
stack Error: `C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\node-gyp\lib\build.js:262:23)
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.19043
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\node-gyp\\bin\\node-gyp.js" "build" "--fallback-to-build" "--module=C:\\Users\\ibra
him.koz\\WebstormProjects\\git-client\\node_modules\\nodegit\\build\\Release\\nodegit.node" "--module_name=nodegit" "--module_path=C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\nodegit\
\build\\Release" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=node-v93"
gyp ERR! cwd C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit
gyp ERR!
node -v v16.13.1
gyp ERR! node-gyp -v v4.0.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\ibrahim.koz\WebstormProjects\git-client\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\ibrahim.koz
\WebstormProjects\git-client\node_modules\nodegit\build\Release\nodegit.node --module_name=nodegit --module_path=C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\Release --napi_ver
sion=8 --node_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\node-pre-gyp\lib\util\compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
node-pre-gyp
ERR! stack     at maybeClose (node:internal/child_process:1064:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
node-pre-gyp ERR!
System Windows_NT 10.0.19043
node-pre-gyp ERR! command
"C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\ibrahim.koz\\WebstormProjects\\git-client\\node_modules\\node-pre-gyp\\bin\\node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit
node-pre-gyp
ERR! node -v v16.13.1
node-pre-gyp ERR! node-pre-gyp -v v0.13.0
node-pre-gyp ERR! not ok
Failed to execute 'C:\Program Files\nodejs\node.exe C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\node-gyp\bin\node-gyp.js build --fallback-to-build --module=C:\Users\ibrahim.koz\WebstormProj
ects\git-client\node_modules\nodegit\build\Release\nodegit.node --module_name=nodegit --module_path=C:\Users\ibrahim.koz\WebstormProjects\git-client\node_modules\nodegit\build\Release --napi_version=8 --node
_abi_napi=napi --napi_build_version=0 --node_napi_label=node-v93' (1)
[nodegit] ERROR - Could not finish install
[nodegit] ERROR - finished with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

我选择yarn 的原因是为了获得更具描述性的错误消息。 我已经安装了python2.7并将其设置为yarn config set msvs_version 2015 -g

yarn config set msvs_version 2017 -g

我的所有尝试都被证明是徒劳的。

您能帮我解决这个问题吗?

【问题讨论】:

    标签: node.js npm


    【解决方案1】:

    你必须升级node-gyp的版本

    使用这个

    sudo npm install -g node-gyp 或者 sudo npm install -g node-gyp@8.4.1

    【讨论】:

      猜你喜欢
      • 2020-05-02
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-23
      • 2018-03-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多