0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

`npm install` はパッケージを使う環境でやろうねという話

Posted at

React NativeのCI環境を一部Dockerにしようとしたところ盛大にハマったので学びを共有しておきます。

iMacをjenkins-slaveとしていた環境で、React nativeのCI環境を作っていました。

  • xcodeはiMacホストのものをつかう
  • jsのバンドルなどはdockerで行う

という環境にしようとしていました。

するとなぜか Mapbox.framework が無くてビルドできないというエラー。開発環境では問題ない。

@mapbox/react-native-mapbox-gl/package.json を見るとこんな記述。

  "scripts": {
    "fetch:ios:sdk": "node ./scripts/download-mapbox-gl-native-ios-if-on-mac.js 3.7.8",
    "fetch:style:spec": ". ./scripts/download-style-spec.sh",
    "format": "npm run lint -- --fix",
    "generate": "node ./scripts/autogenerate",
    "lint": "./node_modules/eslint/bin/eslint.js ./javascript/** ./example/src/** ./__tests__/**",
    "precommit": "lint-staged",
    "preinstall": "npm run fetch:ios:sdk",
    "test": "npm run lint && npm run unittest",
    "unittest": "jest --coverage --verbose",
    "unittest:single": "jest --testNamePattern"
  },

preinstall で fetch:ios:sdk やってる。 fetch:ios:sdkのコマンドは node ./scripts/download-mapbox-gl-native-ios-if-on-mac.js 3.7.8
おお、macで実行しないと Mapbox.framework どダウンロードしない作りになっている。

まなび

ああ、そういえばネイティブコールするパッケージとかもnode_modulesのコピーだけじゃうまくいかないこともあったなぁ。
npm installはパッケージのダウンロード後に、一部環境依存のファイルを生成したり、ダウンロードしたりするんだなぁ。
実際にパッケージを使う環境でnpm installしないとはまることがあるなぁ。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?