2017-09-14 142 views
2

我正在使用的elm項目nixos我無法編譯。這個項目爲我使用macOS的同事編譯成功;也許在我的機器上編譯失敗與我使用NixOS有關。在nixos上使用紗線運行時,elm-make無法編譯

當我運行$ yarn start我得到以下端子輸出:

$ yarn start 
yarn start v0.20.3 
$ webpack-dev-server --env dev 
env dev 
Project is running at http://0.0.0.0:3000/ 
webpack output is served from/
Content not from webpack is served from /home/matthew/backup/azara_work/platform/web/src 
404s will fallback to /index.html 
Running elm-make /home/matthew/backup/azara_work/platform/web/src/App.elm --yes --warn --debug --output /tmp/117814-7766-1wq3nh5.xanii6yldi.js 

,當我試圖在http://0.0.0.0:3000/加載網頁瀏覽器控制檯顯示以下錯誤:

VM1496:1 Uncaught Error: Module build failed: Error: Compiler process exited with error Compilation failed 
events.js:160 
     throw er; // Unhandled 'error' event 
    ^

Error: spawn /home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make ENOENT 
    at exports._errnoException (util.js:1018:11) 
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) 
    at onErrorNT (internal/child_process.js:367:16) 
    at _combinedTickCallback (internal/process/next_tick.js:80:11) 
    at process._tickCallback (internal/process/next_tick.js:104:9) 
    at Module.runMain (module.js:606:11) 
    at run (bootstrap_node.js:389:7) 
    at startup (bootstrap_node.js:149:9) 
    at bootstrap_node.js:504:3 

    at ChildProcess.<anonymous> (/home/matthew/backup/azara_work/platform/web/node_modules/node-elm-compiler/index.js:141:27) 
    at emitTwo (events.js:106:13) 
    at ChildProcess.emit (events.js:191:7) 
    at maybeClose (internal/child_process.js:891:16) 
    at Socket.<anonymous> (internal/child_process.js:342:11) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at Pipe._handle.close [as _onclose] (net.js:497:12) 
    at exports._errnoException (util.js:1018:11) 
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) 
    at onErrorNT (internal/child_process.js:367:16) 
    at _combinedTickCallback (internal/process/next_tick.js:80:11) 
    at process._tickCallback (internal/process/next_tick.js:104:9) 
    at Module.runMain (module.js:606:11) 
    at run (bootstrap_node.js:389:7) 
    at startup (bootstrap_node.js:149:9) 
    at bootstrap_node.js:504:3 

    at ChildProcess.<anonymous> (/home/matthew/backup/azara_work/platform/web/node_modules/node-elm-compiler/index.js:141:27) 
    at emitTwo (events.js:106:13) 
    at ChildProcess.emit (events.js:191:7) 
    at maybeClose (internal/child_process.js:891:16) 
    at Socket.<anonymous> (internal/child_process.js:342:11) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at Pipe._handle.close [as _onclose] (net.js:497:12) 
    at eval (eval at ./src/App.elm (http://0.0.0.0:3000/index.js:4316:1), <anonymous>:1:7) 
    at Object../src/App.elm (http://0.0.0.0:3000/index.js:4316:1) 
    at __webpack_require__ (http://0.0.0.0:3000/index.js:658:30) 
    at fn (http://0.0.0.0:3000/index.js:86:20) 
    at eval (eval at ./src/index.js (http://0.0.0.0:3000/index.js:4324:1), <anonymous>:7:13) 
    at Object../src/index.js (http://0.0.0.0:3000/index.js:4324:1) 
    at __webpack_require__ (http://0.0.0.0:3000/index.js:658:30) 
    at fn (http://0.0.0.0:3000/index.js:86:20) 
    at Object.0 (http://0.0.0.0:3000/index.js:4333:18) 
    at __webpack_require__ (http://0.0.0.0:3000/index.js:658:30) 

./src/App.elm 
Module build failed: Error: Compiler process exited with error Compilation failed 
events.js:160 
     throw er; // Unhandled 'error' event 
    ^

Error: spawn /home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make ENOENT 
    at exports._errnoException (util.js:1018:11) 
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32) 
    at onErrorNT (internal/child_process.js:367:16) 
    at _combinedTickCallback (internal/process/next_tick.js:80:11) 
    at process._tickCallback (internal/process/next_tick.js:104:9) 
    at Module.runMain (module.js:606:11) 
    at run (bootstrap_node.js:389:7) 
    at startup (bootstrap_node.js:149:9) 
    at bootstrap_node.js:504:3 

    at ChildProcess.<anonymous> (/home/matthew/backup/azara_work/platform/web/node_modules/node-elm-compiler/index.js:141:27) 
    at emitTwo (events.js:106:13) 
    at ChildProcess.emit (events.js:191:7) 
    at maybeClose (internal/child_process.js:891:16) 
    at Socket.<anonymous> (internal/child_process.js:342:11) 
    at emitOne (events.js:96:13) 
    at Socket.emit (events.js:188:7) 
    at Pipe._handle.close [as _onclose] (net.js:497:12) 
@ ./src/index.js 2:12-32 
@ multi (webpack)-dev-server/client?http://0.0.0.0:3000 webpack/hot/dev-server ./src/index.js 

看來問題可能有與elm-make有關,因爲它出現在兩個錯誤中。我的路徑上

$ which elm-make 
/home/matthew/.nix-profile/bin/elm-make 

這是一個不同的位置處錯誤報告它正試圖找到elm-make/home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make)路徑發現elm-make。我想知道這是否可能與問題有關。

在錯誤中列出的目錄中,elm-make確實出現經由ls上市時在場:

$ ls /home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/ 
elm elm-make elm-package elm-reactor elm-repl 

然而,當我嘗試運行yarn start的輸出中列出的命令,除了與替換elm-make在此節點模塊路徑中的elm-make,我得到'沒有這樣的文件或目錄'錯誤。

$ ./node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make /home/matthew/backup/azara_work/platform/web/src/App.elm --yes --warn --debug --output /tmp/117814-7422-1p5ad15.q2uqqzd7vi.js 
-bash: ./node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make: No such file or directory 

爲什麼試圖運行時,可能我得到這個「沒有這樣的文件或目錄」錯誤這個「節點模塊」 elm-make當通過ls上市時的可執行文件是清晰可見?

由於我的路徑elm-make與'node-modules'下的路徑位置之間的路徑位置不同,是不是編譯失敗?也許紗線使用了錯誤的紗線。如果是這樣,我怎樣才能設置紗線使用正確的elm-make

如何才能讓yarn start成功編譯該項目?

建議非常感謝;我一直堅持這一點。

回答

3

我建議你讓NIMOS的安裝可選(莫名其妙)。通常最簡單的方法是創建一個每個人都使用的shell.nix,並根據nix完全避免依賴nix。

elm-make不存在的原因是由於ELF解釋器位於NixOS的不同位置。

嘗試ldd ./node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin/elm-make

快速解決將是符號鏈接ls -la $(nix-build -A elmPackages.elm '<nixpkgs>')/bin所有的二進制文件到你的陰謀沙箱。

+1

創建符號鏈接'$ ln -s/home/matthew /。/ home/matthew/backup/azara_work/platform/web/node_modules/elm/Elm-Platform/0.18.0/.cabal-sandbox/bin「中的nix-profile/bin/elm-make'。謝謝! – mherzl