2017-06-28 94 views
2

electron-packager .未在Darwin平臺上安裝來自node_modules的所有模塊。電子包裝商未安裝來自node_modules的所有模塊

當試圖啓動這樣的打包應用程序,會出現以下錯誤:

Uncaught Exception: 
Error: Cannot find module 'sudo-prompt' 
    at Module._resolveFilename (module.js:470:15) 
    at Function.Module._resolveFilename 

兩個package.jsonnode_modules是當前文件夾中。

我試圖完全刪除node_modules並用npm install -production刷新它們,但它無法正確打包應用程序。

的package.json

"main": "app.js", 
    "scripts": { 
    "start": "electron ." 
    }, 
    "devDependencies": { 
    "chokidar": "^1.7.0", 
    "electron": "^1.6.11", 
    "filesize": "^3.5.6", 
    "jquery": "^3.2.1", 
    "keymaster": "^1.6.2", 
    "open": "0.0.5", 
    "peity": "^3.2.1", 
    "sudo-prompt": "^7.1.0", 
    "underscore": "^1.8.3", 
    "unzip-stream": "^0.1.2" 
    }, 
    "dependencies": { 
    "chart.js": "^2.6.0", 
    "filesize": "^3.5.10", 
    "open": "0.0.5", 
    "sudo-prompt": "^7.1.0" 
    } 

electron-packager打包應用程序只有chart.js所有其他依賴失蹤。

.app/Contents/Resources/app $ npm ls 
└─┬ [email protected] 
    ├─┬ [email protected] 
    │ ├─┬ [email protected] 
    │ │ └── [email protected] 
    │ └── [email protected] 
    └── [email protected] 

回答

2

萬一有人面臨着類似的問題:

去除重複dependencies模塊從devDependencies解決的問題。