第一次安裝出現如下錯誤:
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2 gyp verb `which` failed at getNotFoundError (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:13:12) gyp verb `which` failed at F (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:68:19) gyp verb `which` failed at E (C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:80:29) gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\which\which.js:89:16 gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\index.js:44:5 gyp verb `which` failed at C:\Program Files (x86)\Jenkins\jobs\NdbSite-hot-fix-Manual-PreBuild\workspace\src\NdbSite.UI\node_modules\isexe\windows.js:29:5 gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:82:15) gyp verb `which` failed python2 { [Error: not found: python2] code: 'ENOENT' } gyp verb check python checking for Python executable "python" in the PATH gyp verb `which` failed Error: not found: python
因為我電腦上安裝的是Python 3.7,但是這個which命令竟然需要Python 2,於是去StackOver flow找到如下答案。
- 刪除node_modules文件夾
- 運行 npm install --global windows-build-tools
- 運行 npm install
運行npm install --global windows-build-tools命令時又出現一個PowerShell沒有管理員權限的錯誤,於是右鍵以管理員權限運行PowerShell,命令執行成功,Python2成功安裝到C:\Users\test\.windows-build-tools\python27。
再次運行npm install命令后,又出現之前一樣的錯誤。
於是再刪除node_modules目錄,重新運行npm install。居然成功了!