第一次尝试在npm install上创建一个React组件node_module为空

我已经制作了基本的React组件Persons,并将其包含在软件包my-react-components中。但是,当我使用以下方法安装该组件时:

npm install my-react-components

它具有LICENSE,package.json和README.md。但是我的index.js文件丢失了。

这是我要从内部BitBucket存储库安装的软件包。以下是package.json的相关摘录:

   "dependencies": {
       "react": "^16.11.0","react-dom": "^16.11.0","my-react-components": "latest"
       "react-scripts": "3.2.0"
    },"repository": {
        "type": "git","url": "ssh://git@bitbucket.mycompany.com:7999/~myusername/my-react-components.git"
    },

在React组件中,我尝试了各种方法,以便以某种方式导出该组件:

export default Persons;

有什么想法吗?

haofanawori 回答:第一次尝试在npm install上创建一个React组件node_module为空

这是一个疯狂的问题!我希望这个答案对某人有帮助。

结果是,如果一个人检查了npm注册表,则碰巧有一个软件包的确切名称:

https://www.npmjs.com/package/my-react-components

在这种情况下,npm install是从npm注册表而不是内部BitBucket存储库安装的。这就是为什么没有index.js的原因,因为注册表组件没有这样的文件。

修复依赖项以指向BitBucket存储库解决了该问题。作为额外的预防措施,值得重命名该组件:

"dependencies": {
    “my-company-react-components": "git+ssh://git@bitbucket.mycompany.com:7999/~myusername/my-company-react-components.git#master","react": "^16.11.0","react-dom": "^16.11.0","react-scripts": "3.2.0"
  },
本文链接:https://www.f2er.com/2979567.html

大家都在问