Npm postinstall脚本由于不需要依赖性而阻止安装

时间:2018-06-06 19:21:19

标签: reactjs react-native npm npm-install npm-scripts

我正在尝试将npm install一个Web项目放入我的React Native项目中以重用一些代码。现在我们无法将此代码重构为共享项目,因此我必须安装整个Web项目。 React Native显然不需要webpack,但是这个web项目有一个需要webpack的postinstall脚本。我正在重用的代码也不需要它。

我知道我可以使用npm install --ignore-scripts忽略该脚本,但这会禁用包括我的所有脚本,并且我需要运行安装后脚本。

如果我尝试安装,我遇到了在postinstall脚本中需要webpack的问题。这里有另一种解决方法吗?

如何将此软件包安装到我的React Native项目中,以后能够在我的package.json中轻松更新它?使用--ignore-scripts与其他依赖项分开来手动运行它是没有意义的。

"scripts": {
    "compile": "babel src --out-dir build --ignore '**/__mocks__/*.js' --copy-files",
    "test:update": "jest -u",
    "start": "node server",
    "build": "webpack -p --devtool source-map --progress --display-modules",
    "lint:old": "./node_modules/.bin/eslint --ignore-path .gitignore ./src/**/*.js ./__test__/**/*.js ./*.js",
    "clean": "rimraf dist",
    "prebuild": "npm run clean",
    "pretest": "npm run build",
    "lint": "./node_modules/.bin/eslint --ignore-path .gitignore ./src/**/*.js ./__tests__/**/*.js ./*.js",
    "test": "jest --verbose --no-cache",
    "postinstall": "postinstall-build dist \"npm run build\""
  },

0 个答案:

没有答案
相关问题