久久久久久久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?(如何在電子應用程序中訪問相機/網絡攝像頭?)
主站蜘蛛池模板: 亚洲福利网 | 男女操操操 | 国产日韩欧美在线 | 91视频在线观看视频 | 国产成人精品一区二区三区在线 | 久久综合伊人 | 久久久网站 | 久久精品一区二区三区四区 | www婷婷| 怡红院在线播放 | 视频在线一区二区 | 国产视频一区在线播放 | av在线播放不卡 | 成人毛片一区二区三区 | 亚洲激情在线 | 在线成人免费 | 国产日韩av在线 | 欧美在线观看一区二区 | 免费黄色一级片 | 午夜在线免费视频 | 欧美在线免费观看 | 成人永久免费视频 | 精品国产999久久久免费 | 国产麻豆91| 欧美视频免费在线观看 | 狠狠做| 国产一区在线看 | 久草久草久草 | 国产欧美久久久 | 成人夜色 | 欧美国产一区二区 | av四虎| 亚洲精品免费看 | 国产99页 | 动漫av在线 | 久久国产一区二区 | 在线免费观看毛片 | 在线观看视频一区二区三区 | 成人精品免费视频 | 91亚洲成人 | 求av网站|