首页 > 解决方案 > 分叉的 npm 包上没有发生安装后构建步骤

问题描述

我在这里分叉了这个repo ,非常简单。现在我指出我的项目使用我的叉子。之后我一切看起来都很好,只是文件夹丢失了。我知道需要运行以生成这些文件,并且可以手动执行此操作,但 Wix 版本以某种方式在安装包时运行构建步骤。与原版的唯一区别是我更改了一些 iOS 代码。官方 npm 包(即您可以按名称安装的包)在安装后是否会获得一些额外的爱?我错过了什么?package.jsonnpm installlib/distnpm run build

没有太多代码要展示,但我会展示 package.json 文件的脚本部分......

"scripts": {
    "build": "rm -rf ./lib/dist && tsc",
    "prestart": "npm run build",
    "pretest-js": "npm run build",
    "pretest-unit-ios": "npm run build",
    "pretest-unit-android": "npm run build",
    "test": "node scripts/test",
    "start": "node ./scripts/start",
    "pretest-e2e-ios-release": "npm run build",
    "clean": "node ./scripts/clean",
    "test-e2e-ios": "node ./scripts/test-e2e --ios",
    "test-e2e-ios-release": "node ./scripts/test-e2e --ios --release",
    "test-unit-ios": "node ./scripts/test-unit --ios",
    "test-unit-android": "node ./scripts/test-unit --android",
    "test-js": "node ./scripts/test-js",
    "xcode": "open example/ios/NotificationsExampleApp.xcodeproj",
    "androidStudio": "open -a /Applications/Android\\ Studio.app ./example/android",
    "prerelease": "npm run build",
    "release": "node ./scripts/release",
    "generate-changelog": "gren changelog",
    "docusaurus": "npm start --prefix website"
},

更新:我prepare在我的 fork 中添加了一个条目,package.json创建了 dist 文件。我仍然很好奇为什么原始回购会自动完成。

标签: javascriptnode.jsreact-native

解决方案


这个问题和我的有很多共同点,甚至可能是骗人的。这个答案让我读了几遍,但它让我阅读了节点文档(喘气!)。我推断包作者构建并发布到 npm(这很明显),但是 npm install 实际上并没有去 git 来获取文件,而是他们有一个来自发布过程的 tar。这对我来说是缺失的部分。无论如何,如果您想在安装时拥有自己的个人包,请使用prepare.


推荐阅读