Py学习  »  Git

如何在Laravel Mix中导入Github的分叉npm包?

Wilson • 3 年前 • 1388 次点击  

在里面 package.json ,我有:

"vue-search-select": "github:my-github-account/vue-search-select"

然后跑 npm install ,没有错误。

在里面 app.js ,我尝试导入分叉包:

import { ModelSelect } from 'vue-search-select';

当我跑的时候 npm run watch ,收到以下信息:

Module not found: Error: Can't resolve 'vue-search-select'

更新:

我比较了原始版本和分叉版本 node_modules :原文包含 dist 文件夹,但分叉版本没有。在github中,原来的一个也没有这个文件夹。和 距离 包括在 .gitignore .

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/129713
文章 [ 2 ]  |  最新文章 3 年前
Wilson
Reply   •   1 楼
Wilson    3 年前

最后,我找到了一个解决方案:

添加 "prepare": "npm run lib:build" (或者其他取决于软件包的构建方式,您可以将其签入。) package.json )到 scripts 属于 包裹json 到分叉的包裹。然后推到github。

然后,在使用分叉包的项目中,只需保持 "package-name": "github:my-github-account/package-name" 在里面 包裹json 然后跑 npm install 再一次没有其他变化。

VonC
Reply   •   2 楼
VonC    3 年前

我明白,因为 package.json GitHub URL ,从1.1.65版开始,您可以将GitHub URL称为 foo:user/foo-project seen here .

但我还是建议 more complete URL instead :

git+ssh://user@hostname:project.git#commit-ish
git+ssh://user@hostname/project.git#commit-ish
git+http://user@hostname/project/blah.git#commit-ish
git+https://user@hostname/project/blah.git#commit-ish

这样,您可以控制该方案(HTTPS或SSH),并可以检查使用了哪些凭据(HTTPS的缓存用户名/密码或SSH的私钥)。

这个 OP Wilson 评论 the discussion 加上 dist/ 回购协议可能是一种选择,正如 in here .
A. prepare script 可以在包中声明。json,例如 this one .

  "scripts": {
    "build": "tsc",
    "prepare": "npm run build"
  },

正如威尔逊的 answer

重要的是 准备 剧本是 添加在分叉包装中 , 在使用包的项目中。