tekitoumemo’s diary

思ったことを書くだけ。長文版Twitter

App Service on Linuxでnpm iするとシンボリックリンクが使えなくなってエラーになる

みんなの洋楽ランキングのReactを最新にしたらデプロイ時に意味わからないエラーが発生しました。

エラーログ

Command: /home/site/repository/deploy.sh
Handling ASP.NET Core Web Application deployment.
  Restore completed in 721.71 ms for /home/site/repository/library/Client/Client.csproj.
  Restore completed in 62.82 ms for /home/site/repository/library/DapperSlackOff/DapperSlackOff/DapperSlackOff.csproj.
  Restore completed in 489.23 ms for /home/site/repository/src/mygkrnk.csproj.
react@0.0.0 /home/site/repository/src
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/chokidar/node_modules/fsevents):
`-- (empty)
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! Linux 4.4.0-128-generic
npm ERR! argv "/opt/nodejs/6.11.0/bin/node" "/usr/bin/node_modules/npm/bin/npm-cli.js" "install"
An error has occurred during web site deployment.
npm ERR! node v6.11.0
npm ERR! npm  v3.10.10
npm install failed
npm ERR! path ../esprima/bin/esparse.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall symlink

npm ERR! enoent ENOENT: no such file or directory, symlink '../esprima/bin/esparse.js' -> '/home/site/repository/src/node_modules/.bin/esparse'
npm ERR! enoent ENOENT: no such file or directory, symlink '../esprima/bin/esparse.js' -> '/home/site/repository/src/node_modules/.bin/esparse'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /home/site/repository/src/npm-debug.log
npm ERR! code 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/chokidar/node_modules/fsevents):\nnpm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})\nnpm ERR! Linux 4.4.0-128-generic\nnpm ERR! argv "/opt/nodejs/6.11.0/bin/node" "/usr/bin/node_modules/npm/bin/npm-cli.js" "install"\nnpm ERR! node v6.11.0\nnpm ERR! npm  v3.10.10\nnpm ERR! path ../esprima/bin/esparse.js\nnpm ERR! code ENOENT\nnpm ERR! errno -2\nnpm ERR! syscall symlink\n\nnpm ERR! enoent ENOENT: no such file or directory, symlink '../esprima/bin/esparse.js' -> '/home/site/repository/src/node_modules/.bin/esparse'\nnpm ERR! enoent ENOENT: no such file or directory, symlink '../esprima/bin/esparse.js' -> '/home/site/repository/src/node_modules/.bin/esparse'\nnpm ERR! enoent This is most likely not a problem with npm itself\nnpm ERR! enoent and is related to npm not being able to find a file.\nnpm ERR! enoent \n\nnpm ERR! Please include the following file with any support request:\nnpm ERR!     /home/site/repository/src/npm-debug.log\nnpm ERR! code 1\n/opt/Kudu/bin/Scripts/starter.sh /home/site/repository/deploy.sh

よくわからないけどシンボリックリンクが貼れないっぽい。あやしそうなこいつを調べてみます。

no such file or directory, symlink '../esprima/bin/esparse.js

Azure App Serviceのsshディレクトリがどうなってるか調べてみます。

-????????? ? ?      ?           ?            ? esparse
-????????? ? ?      ?           ?            ? esvalidate
-????????? ? ?      ?           ?            ? tsc

は、なにこれ

いみわかんね。

お友達にfreeBSD大好きな変態がいるので聞いてみました。

お友達「わかんね。」

statシステムコールで想定していない属性値になっているみたいで、要はファイルシステムがぶっこわれているようです。

完全詰みました。これのせいでリリースができません、いや出来るんですが、CircleCIで設定するコストを考えすぎたらだるすぎて困りました。

どうしてもkuduをつかいたい。

いろいろ迷ってたら以下の記事を見つけました。
stackoverflow.com

dockerやらwindows環境でシンボリックリンクが貼れない場合はnpm iに以下のオプションをつけるとシンボリックリンクを使わずにインストールしてくれるようです。

npm install --no-bin-links

これでやっと成功しました。
f:id:tekitoumemo:20190623194254p:plain

あまり良くわかってないけど、App Serviceはコンテナで動いてるのかな?とりあえず、オンプレと同じようなことをするとファイルシステムがおかしくなることがあるっぽいのでこれはつけといたほうが良いかもしれません。