Reactjs 未找到模块:错误:Can';t解析“pp共享组件”-反应Jenkins中的组件共享库

Reactjs 未找到模块:错误:Can';t解析“pp共享组件”-反应Jenkins中的组件共享库,reactjs,typescript,jenkins,shared-libraries,rollupjs,Reactjs,Typescript,Jenkins,Shared Libraries,Rollupjs,我有一个名为pp共享组件的React库。它存在于github repo上,因此要安装它,我在我的package.json文件中执行以下操作 "dependencies": { "pp-shared-components": "git+ssh://git@github.com/{org}/pp-shared-components.git#master", } 在pp共享组件repo中,我有一个index.js文件,它导入React组件,然后像这样导出 import ContentHead

我有一个名为
pp共享组件的React库
。它存在于github repo上,因此要安装它,我在我的
package.json
文件中执行以下操作

"dependencies": {
    "pp-shared-components": "git+ssh://git@github.com/{org}/pp-shared-components.git#master",
}
pp共享组件
repo中,我有一个
index.js
文件,它导入React组件,然后像这样导出

import ContentHeader from './components/content-header/ContentHeader.js';
import Wizard from './components/wizard/Wizard.js';

export {
  ContentHeader,
  Wizard
}
我使用
rollup
构建我的库

我的
pp共享组件中的
package.json
如下所示

{
  "name": "pp-shared-components",
  "version": "1.0.0",
  "description": "PP Shared Library for Components.",
  "main": "build/index.cjs.js",
  "module": "build/index.esm.js",
  "browser": "build/index.js",
  "style": "build/index.css",
  "files": [
    "build"
  ],
  "scripts": {
    "build": "rollup -c",
    "watch": "rollup -c --watch",
    "lint": "eslint --ext .js,.jsx .",
    "prepare": "npm run build"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/{org}/pp-shared-components.git"
  },
  "publishConfig": {
    "access": "public"
  },
  "devDependencies": {
    ...
    "rollup": "^1.17.0",
    "rollup-plugin-babel": "^4.3.3",
    "rollup-plugin-commonjs": "^10.0.1",
    "rollup-plugin-filesize": "^6.1.1",
    "rollup-plugin-json": "^4.0.0",
    "rollup-plugin-local-resolve": "^1.0.7",
    "rollup-plugin-node-builtins": "^2.1.2",
    "rollup-plugin-node-externals": "^2.0.1",
    "rollup-plugin-node-globals": "^1.4.0",
    "rollup-plugin-node-resolve": "^5.2.0",
    "rollup-plugin-peer-deps-external": "^2.2.0",
    "rollup-plugin-postcss": "^2.0.3",
    "rollup-plugin-scss": "^1.0.2"
  },
  "peerDependencies": {
    ...
  },
  "dependencies": {
    ...
  }
}
然后我可以像这样导入另一个项目中的组件

import { ContentHeader, Wizard } from 'pp-shared-components';
这一切都可以在本地正常工作,但是,当我通过Jenkins运行它时,在控制台中出现以下错误

[INFO] ERROR in ./screens/main/Main.js
[INFO] Module not found: Error: Can't resolve 'pp-shared-components' in '/var/lib/jenkins/data/workspace/pp/src/main/client/screens/main'
[INFO]  @ ./screens/main/Main.js 6:15-55
[INFO]  @ ./app/App.js
[INFO]  @ ./index.js
查看Jenkins中
node\u modules
文件夹中的
pp shared components
文件夹,所有文件夹和文件与我的本地版本中的文件夹和文件完全相同

我注意到,在VSCode中,有一个小的工具提示

module "/Users/{users}/git/pp/node_modules/pp-shared-components/build/index.cjs"
Could not find a declaration file for module 'pp-shared-components'. 
'/Users/{users}/git/pp/node_modules/pp-shared-components/build/index.cjs.js' implicitly has an 'any' type.
  Try `npm install @types/pp-shared-components` if it exists or add a new declaration (.d.ts) file containing `declare module 'pp-shared-components';`ts(7016)
现在,我在
pp共享组件
项目中的任何地方都不使用
typescript

我是否需要在项目中的某个地方添加
.d.ts
文件,同时在整个项目中使用typescript

现在有点不知所措,需要知道下一步该做什么,如果是添加
.d.ts
文件,那么这样做涉及到什么?它是否像添加
声明模块'pp shared components'
那么简单


任何帮助都将不胜感激。

嗨!你最终解决问题了吗?我面临着类似的问题!谢谢!你最终解决问题了吗?我面临着类似的问题!谢谢