• node npm install引用安装依赖包更改为私有库地址


    背景:项目使用了bpmn.js作为前端的流程引擎,但是需要更改配置文件和映射关系,或者直接修改源码,但是通过npm install安装的是默认的git 地址,于是就需要将bpmn.js拷贝一份到公司的私有库,然后前端引用的git的地址变为私有库的地址,好了

    看效果

    步骤如下

    第一,建立自己的私有库(略过此步)

    第二,将bpmn.js的代码上传到我们的私有库git的地址(此步略过)

    第三,将项目引用的git的地址更改为私有库地址

    1、看我们package.json中的配置

    1. {
    2. "name": "bpmn",
    3. "version": "0.0.1",
    4. "description": "A process designerI",
    5. "keywords": [
    6. "bpmn",
    7. "bpmn.js",
    8. "vue"
    9. ],
    10. "repository": {
    11. ....
    12. },
    13. "scripts": {
    14. ...
    15. },
    16. "dependencies": {
    17. "bpmn-js-sketchy": "^0.5.3",
    18. "bpmn-js-task-resize": "^1.2.0",
    19. "bpmn-js-token-simulation": "^0.10.0",
    20. "core-js": "^3.8.1",
    21. "diagram-js-minimap": "^2.0.4",
    22. "highlight.js": "^10.5.0",
    23. "js-base64": "^3.7.2",
    24. "min-dash": "^3.5.2",
    25. "vue": "^2.6.11",
    26. "vue-router": "^3.4.9",
    27. "x2js": "^3.4.3",
    28. "xml-js": "^1.6.11"
    29. },
    30. "devDependencies": {
    31. "@vue/cli-plugin-babel": "~4.5.0",
    32. "@vue/cli-plugin-eslint": "~4.5.0",
    33. "@vue/cli-service": "~4.5.0",
    34. "@vue/compiler-sfc": "^3.0.1",
    35. "@vue/eslint-config-prettier": "^5.0.0",
    36. "axios": "^0.21.1",
    37. "babel-eslint": "^10.1.0",
    38. "bpmn-js": "^8.8.3",
    39. "bpmn-js-properties-panel": "^0.37.2",
    40. "camunda-bpmn-moddle": "^4.4.1",
    41. "compression-webpack-plugin": "^6.1.1",
    42. "element-ui": "^2.13.2",
    43. "eslint": "^6.7.2",
    44. "eslint-plugin-prettier": "^3.1.0",
    45. "eslint-plugin-vue": "^6.2.2",
    46. "fs-extra": "^8.1.0",
    47. "sass": "^1.30.0",
    48. "sass-loader": "^8.0.2",
    49. "script-ext-html-webpack-plugin": "^2.1.5",
    50. "terser-webpack-plugin": "^4.2.3",
    51. "vue-template-compiler": "^2.6.11",
    52. "webpack-bundle-analyzer": "^3.9.0",
    53. "cross-env": "^7.0.3"
    54. },
    55. "eslintConfig": {
    56. ...
    57. },
    58. "browserslist": [
    59. "> 1%",
    60. "last 2 versions",
    61. "not dead"
    62. ],
    63. "license": "Apache"
    64. }

    可以看到直接通过npm install的方式,默认是安装的是bpmn.js 8.8.3版本

    所以,为了安全与稳定起见,我们项目也应该安装该版本的

    于是,私有库建立该分支,命名为

    Branch_v8.8.3

     同时,修改引用依赖

    "bpmn-js": "git+http://xxxx/bpmn-js.git#Branch_v8.8.3",

    具体如下 

    1. {
    2. "name": "bpmn",
    3. "version": "0.0.1",
    4. "description": "A process designerI",
    5. "keywords": [
    6. "bpmn",
    7. "bpmn.js",
    8. "vue"
    9. ],
    10. "repository": {
    11. ....
    12. },
    13. "scripts": {
    14. ...
    15. },
    16. "dependencies": {
    17. "bpmn-js-sketchy": "^0.5.3",
    18. "bpmn-js-task-resize": "^1.2.0",
    19. "bpmn-js-token-simulation": "^0.10.0",
    20. "core-js": "^3.8.1",
    21. "diagram-js-minimap": "^2.0.4",
    22. "highlight.js": "^10.5.0",
    23. "js-base64": "^3.7.2",
    24. "min-dash": "^3.5.2",
    25. "vue": "^2.6.11",
    26. "vue-router": "^3.4.9",
    27. "x2js": "^3.4.3",
    28. "xml-js": "^1.6.11"
    29. },
    30. "devDependencies": {
    31. "@vue/cli-plugin-babel": "~4.5.0",
    32. "@vue/cli-plugin-eslint": "~4.5.0",
    33. "@vue/cli-service": "~4.5.0",
    34. "@vue/compiler-sfc": "^3.0.1",
    35. "@vue/eslint-config-prettier": "^5.0.0",
    36. "axios": "^0.21.1",
    37. "babel-eslint": "^10.1.0",
    38. "bpmn-js": "git+http://xxxx/bpmn-js.git#Branch_v8.8.3",
    39. "bpmn-js-properties-panel": "^0.37.2",
    40. "camunda-bpmn-moddle": "^4.4.1",
    41. "compression-webpack-plugin": "^6.1.1",
    42. "element-ui": "^2.13.2",
    43. "eslint": "^6.7.2",
    44. "eslint-plugin-prettier": "^3.1.0",
    45. "eslint-plugin-vue": "^6.2.2",
    46. "fs-extra": "^8.1.0",
    47. "sass": "^1.30.0",
    48. "sass-loader": "^8.0.2",
    49. "script-ext-html-webpack-plugin": "^2.1.5",
    50. "terser-webpack-plugin": "^4.2.3",
    51. "vue-template-compiler": "^2.6.11",
    52. "webpack-bundle-analyzer": "^3.9.0",
    53. "cross-env": "^7.0.3"
    54. },
    55. "eslintConfig": {
    56. ...
    57. },
    58. "browserslist": [
    59. "> 1%",
    60. "last 2 versions",
    61. "not dead"
    62. ],
    63. "license": "Apache"
    64. }

    最终,npm install,可以发现我们构建注入的依赖,node_modules如图,已经变成了我们私有库的地址,接下来我们就可以在Branch_v8.8.3分支上修改源码了

    参考文章:
    npm 安装私有 git 包 - 走看看

  • 相关阅读:
    vuex为什么要存在?它与浏览器缓存的区别?
    国民技术Cortex-M0系列单片机IAP升级
    爆肝3万字,最硬核丨Mysql 知识体系、命令全集 【建议收藏 】
    【TA-霜狼_may-《百人计划》】美术2.7 Metallic 与 Speculer流程
    微短剧:爱优腾、抖快、喜马拉雅的新航线
    Yii post()追加数据,模块之间的调用runAction
    py9_详解 Python 类属性/类方法 以及如何转换类方法和静态方法
    文心一言 vs. GPT-4: 全面比较
    elementUI textarea可自适应文本高度的文本域
    理想之光不灭
  • 原文地址:https://blog.csdn.net/weixin_40918145/article/details/126412869