1. 程式人生 > 其它 >記錄:npm install出錯( Can‘t find Python executable “python“, you can set the PYTHON env variable.)

記錄:npm install出錯( Can‘t find Python executable “python“, you can set the PYTHON env variable.)

技術標籤:node.js

  • 今天在進行renren-fast前端部署的時候,執行npm install後失敗,出錯如下:
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (F:\vscode\workrome\renren\renren-fast-vue\node_modules\
[email protected]
@node-gyp\lib\configure.js:484:19) gyp ERR! stack at PythonFinder.<anonymous> (F:\vscode\workrome\renren\renren-fast-vue\node_modules\[email protected]@node-gyp\lib\configure.js:509:16) gyp ERR! stack at callback (F:\vscode\workrome\renren\renren-fast-vue\node_modules\
[email protected]
@graceful-fs\polyfills.js:295:20) gyp ERR! stack at FSReqCallback.oncomplete (fs.js:183:21) gyp ERR! System Windows_NT 10.0.19041 gyp ERR! command "F:\\node\\setupPath\\node.exe" "F:\\vscode\\workrome\\renren\\renren-fast-vue\\node_modules\\[email protected]@node-gyp\\bin\\node-gyp.js"
"rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library=" gyp ERR! cwd F:\vscode\workrome\renren\renren-fast-vue\node_modules\[email protected]@node-sass gyp ERR! node -v v14.15.3 gyp ERR! node-gyp -v v3.8.0 gyp ERR! not ok Build failed with error code: 1 [npminstall:runscript:error] [email protected] scripts.postinstall run "node scripts/build.js" error: Error [RunScriptError]: Run "C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1 at ChildProcess.<anonymous> (F:\node\setupPath\node_global\node_modules\cnpm\node_modules\runscript\index.js:96:21) at ChildProcess.emit (events.js:315:20) at maybeClose (internal/child_process.js:1048:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) { stdio: [Object], exitcode: 1 } × Install fail! RunScriptError: post install error, please remove node_modules before retry! Run "C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1 RunScriptError: Run "C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js" error, exit code 1 at ChildProcess.<anonymous> (F:\node\setupPath\node_global\node_modules\cnpm\node_modules\runscript\index.js:96:21) at ChildProcess.emit (events.js:315:20) at maybeClose (internal/child_process.js:1048:16) at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5) npminstall version: 3.28.0 npminstall args: F:\node\setupPath\node.exe F:\node\setupPath\node_global\node_modules\cnpm\node_modules\npminstall\bin\install.js --fix-bug-versions --china --userconfig=C:\Users\asus\.cnpmrc --disturl=https://npm.taobao.org/mirrors/node --registry=https://r.npm.taobao.org node-sass
  • 從上面看這句話Can't find Python executable "python", you can set the PYTHON env variable.,看了部落格知道是少了python2.7這個環境,所以下載python2.7,並且配置了環境變數,下載和安裝python2.7我是看了這位老哥的部落格。https://blog.csdn.net/u013925378/article/details/83210779
  • 安裝完後,我開心地又執行了一遍npm install,果然事情沒有這麼簡單,又報了下面的錯誤。
在此解決方案中一次生成一個專案。若要啟用並行生成,請新增“/m”開關。
生成啟動時間為 2021/1/5 14:24:39。
節點 1 上的專案“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.sln”(預設目標)。
ValidateSolutionConfiguration:
  正在生成解決方案配置“Release|x64”。
專案“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.sln”(1)正在節點 1 上生成“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass
\build\binding.vcxproj.metaproj”(2) (預設目標)。
專案“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.vcxproj.metaproj”(2)正在節點 1 上生成“F:\vscode\workrome\renren\renren-fast-vue\node_modu
les\node-sass\build\src\libsass.vcxproj”(3) (預設目標)。
F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: 未找到匯入的專案“F:\Microsoft.Cpp.Default.props”。請
確認 <Impor
t> 宣告中的路徑正確,且磁碟上存在該檔案。
已完成生成專案“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\src\libsass.vcxproj”(預設目標)的操作 - 失敗。

已完成生成專案“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.vcxproj.metaproj”(預設目標)的操作 - 失敗。

已完成生成專案“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.sln”(預設目標)的操作 - 失敗。


生成失敗。

“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.sln”(預設目標) (1) ->
“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\binding.vcxproj.metaproj”(預設目標) (2) ->
“F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\src\libsass.vcxproj”(預設目標) (3) ->
  F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: 未找到匯入的專案“F:\Microsoft.Cpp.Default.props”。
請確認 <Imp
ort> 宣告中的路徑正確,且磁碟上存在該檔案。

    0 個警告
    1 個錯誤

已用時間 00:00:00.71
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 (F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command "F:\\node\\setupPath\\node.exe" "F:\\vscode\\workrome\\renren\\renren-fast-vue\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass
gyp ERR! node -v v14.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})    

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     F:\node\setupPath\node_cache\_logs\2021-01-05T06_24_42_870Z-debug.log
  • 看了上述的報錯,簡單地看(
F:\vscode\workrome\renren\renren-fast-vue\node_modules\node-sass\build\src\libsass.vcxproj(20,3): error MSB4019: 未找到匯入的專案“F:\Microsoft.Cpp.Default.props”。
請確認 <Imp
ort> 宣告中的路徑正確,且磁碟上存在該檔案。

),就是少了這個檔案,裂開了,我的資料夾根本就沒有這個檔案,怎麼搞,有查了一下部落格,明白了,這個是因為被牆了,檔案下載不下來,還就直接報錯,所以整了一下,就決定用cnpm install來安裝依賴,安裝cnpm百度一堆部落格,我這裡就不講了,我直接就cnpm install,大功告成。

  • 以上問題就是我自己遇到的,可能並不適合每一個人,希望對需要的人有幫助。