本文介绍了预发布无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在测试npm脚本以建立我的项目依赖项.

I am testing on npm scripts to build my project dependency.

我的想法来自 https://github.com/ParsePlatform/parse-server 在存储库中的代码给我留下了深刻的印象,并不意味着npm install之后的node_modules中的代码.

My idea comes from https://github.com/ParsePlatform/parse-server which impressed me by code in repository doesn't mean code in node_modules after npm install.

下面是我的testmodule结构

Below is my testmodule structure

src/index.js
package.json

这是我的package.json内容

and this is my package.json content

{
  "name": "testmodule",
  "version": "1.0.0",
  "description": "",
  "main": "lib/index.js",
  "scripts": {
    "build": "babel src/ -d lib/",
    "prepublish": "npm run build"
  },
  "devDependencies": {
    "babel-cli": "^6.18.0",
    "babel-core": "^6.18.2"
  }
}

这是运行npm install testmodule

node_modules/testmodule/lib/index.js
node_modules/testmodule/package.json

src文件夹不应该在这里.

which is src folder should not be here.

但是运行npm install后,它与推送到git存储库时完全相同.

But after I run npm install, it is exactly the same as when I push to my git repository.

请注意,我在自己的服务器中使用 GitLab .

Please take note that I am using GitLab in my own server.

所以我的问题是:

  1. 是否需要进行预发布运行?

  1. Is there anything that i'm missing to make prepublish run?

parse-server代码的哪些部分会使src文件夹和其他文件在安装后不存在?

Which part of parse-server code makes the src folder and other files not there after install?

推荐答案

您如何运行npm install?

根据有关npm脚本的文档,预发布脚本将在软件包之前运行已发布.(也可在本地npm install上运行,不带任何参数.)".显然,预发布脚本仅在npm publishnpm install <local directory>上运行.

According to the documentation on npm scripts, the prepublish script is run "BEFORE the package is published. (Also run on local npm install without any arguments.)". It seems clear that the prepublish script is only run on npm publish or npm install <local directory>.

如果您尝试直接通过URL从本地gitlab服务器安装,将有效-脚本将不会运行.解决方案将是在本地安装,除非您愿意将您的软件包&将其推送到npm存储库或为私有npm存储库付费.这是我在开发软件包之前准备将其公开之前所做的事情.

If you are trying to install directly from your local gitlab server via a URL, this will not work - the script will not be run. The solution would be to install locally unless you're willing to open source your package & push it to the npm repository or pay for a private npm repository. This is what I have done during development of packages before they're ready to be made public.

这篇关于预发布无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 08:07