0
0

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.

devDependencies と dependencies を使い分けず pkg でのビルドに失敗した

0
Posted at

正しい例

package.json
{
  "name": "hogehoge",
  "scripts": {
    "build": "npm run-script build:view && npm run-script build:bin",
    "build:view": "react-scripts build",
    "build:bin": "pkg .",
    "start": "react-scripts start",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "carlo": "^0.9.11"
  },
  "devDependencies": {
    "react-scripts": "^2.1.1",
    "pkg": "^4.3.4"
  },
  "homepage": "https://domain",
  "bin": {
    "hogehoge": "index.js"
  },
  "pkg": {
    "assets": "build/**/*",
    "targets": ["node8"]
  }
}

おこる間違い

上記の devDependencies に書かれたものを dependencies に入れると
pkg はそれらもファイルに含めてしまう。
余計な容量が増えるしブラウザ向けの ( es-module で書かれた ) コードなどを読もうとしてエラーが発生する場合がある。

0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?