久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

npm:在 Electron 應用程序中執行命令時找不到命令

npm: command not found when executing commands in Electron app(npm:在 Electron 應用程序中執行命令時找不到命令)
本文介紹了npm:在 Electron 應用程序中執行命令時找不到命令的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在開發一個電子應用程序,在該應用程序中,我使用 child_process.exec 執行 shell 命令.我運行的命令之一是 npm run start;這在開發環境中完美運行,但是當我為生產構建應用程序時,所有 npm 命令都失敗并顯示以下錯誤:

I'm working on an electron app and within the app, I execute shell commands using child_process.exec. One of the commands I run is npm run start; this works perfectly in a dev environment but when I build the application for production all npm commands fail with showing the following error:

   Error: Command failed: npm run start
   /bin/sh: npm: command not found


    at ChildProcess.exithandler (child_process.js:287)
    at emitTwo (events.js:126)
    at ChildProcess.emit (events.js:214)
    at maybeClose (internal/child_process.js:925)
    at Socket.stream.socket.on (internal/child_process.js:346)
    at emitOne (events.js:116)
    at Socket.emit (events.js:211)
    at Pipe._handle.close [as _onclose] (net.js:554)

我嘗試通過運行以下命令以調試模式運行應用程序 open MyApp.app/Contents/MacOS/MyApp 并且 npm 命令成功運行且沒有錯誤.

I tried running the application in debug mode by running the following command open MyApp.app/Contents/MacOS/MyApp and the npm commands run successfully with no errors.

可能是什么問題?

推薦答案

打包后的應用程序中$PATH環境變量錯誤的問題,在開發中是可以的,因為應用程序是從終端啟動的,它可以訪問$BASH 配置文件.

The issue that the environment variable of $PATH is wrong inside the packaged app, it works in development because the application is launched from the terminal which gives it access to the $BASH profile.

為了解決這個問題,我使用了這個包 fix-path.我安裝了軟件包并在文件頂部添加了以下代碼段

To solve this problem I used this package fix-path. I installed the package and added the following snippet at the top of the file

if (process.env.NODE_ENV === 'production') {
  const fixPath = require('fix-path');

  fixPath();
}

我在 GitHub 上瀏覽了這個 issue 后得出了這個答案.感謝@Seblor

I came to this answer after going through this issue on GitHub. Thanks to @Seblor

這篇關于npm:在 Electron 應用程序中執行命令時找不到命令的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to fix BrowserWindow is not a constructor error when creating child window in Electron renderer process(在 Electron 渲染器進程中創建子窗口時如何修復 BrowserWindow 不是構造函數錯誤) - IT屋-程序員軟件開發技術
mainWindow.loadURL(quot;https://localhost:3000/quot;) show white screen on Electron app(mainWindow.loadURL(https://localhost:3000/) 在 Electron 應用程序上顯示白屏)
Electron webContents executeJavaScript : Cannot execute script on second on loadURL(Electron webContents executeJavaScript:無法在第二個 loadURL 上執行腳本)
how to use electron browser window inside components in angular-cli?(如何在angular-cli的組件內使用電子瀏覽器窗口?)
ElectronJS - sharing redux store between windows?(ElectronJS - 在 Windows 之間共享 redux 存儲?)
How to access camera/webcamera inside electron app?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 国产精品99久久久久久动医院 | 久久久久久国产 | 国产乱码精品1区2区3区 | 久久国产视频网站 | 日韩欧美在线免费 | 久久久精品一区 | 性色av一区二区三区 | 国产精品永久 | 欧美国产一区二区 | 精品国产精品国产偷麻豆 | 国产大学生情侣呻吟视频 | 国产一区二区三区视频 | 国产精品视频 | 国产精品视频在线播放 | 久久91| 蜜桃综合在线 | 日日噜噜噜夜夜爽爽狠狠视频97 | av网站在线播放 | 免费成人午夜 | 午夜激情网| 成人午夜精品 | 日韩一区二区三区在线看 | 国产精品久久久久久久久久久久 | 国产一区免费 | 福利一区二区在线 | 粉嫩av| 亚洲黄色一级毛片 | 亚洲毛片 | 亚洲人成一区二区三区性色 | 久久久久国产一区二区三区四区 | 中文字幕一区二区三区四区五区 | 伊人影院在线观看 | 粉嫩国产精品一区二区在线观看 | 亚洲欧美国产视频 | 免费欧美 | 久久神马 | 国产精品福利视频 | 日韩欧美精品一区 | 欧美操操操| 国产一区二区观看 | 亚洲 欧美 在线 一区 |