我已经在GitHub上创建了一个npm软件包,对其进行了更改,现在我想直接从GitHub在我的Meteor应用中安装该软件包。
我的package.json看起来像这样:
{
"dependencies": {
"semantic-ui-react": "git+https://git@github.com/nolandg/Semantic-UI-React.git",
}
}
Run Code Online (Sandbox Code Playgroud)
然后我跑
meteor npm install
Run Code Online (Sandbox Code Playgroud)
这似乎工作正常,并告诉我它已经安装了软件包:
semantic-ui-react@0.61.6 (git+https://git@github.com/nolandg/Semantic-UI-React.git#f27d5c736e5de1eed0acf7769f18caee57578526)
Run Code Online (Sandbox Code Playgroud)
确实,该软件包出现在node_modules文件夹中。但是,当我尝试启动Meteor应用程序时,出现以下错误:
Cannot set property '/my-website/node_modules/semantic-ui-react/package.json' of undefined
at Resolver._resolvePkgJsonMain (/tools/isobuild/resolver.js:320:9)
Run Code Online (Sandbox Code Playgroud)
是否有人直接从GitHub成功在Meteor应用程序中成功安装了npm软件包?我不知道这一点。谢谢!
流星版本:1.4.2.3
从 git 获取数据包时无法工作的主要原因是它没有配置为以这种方式工作。这不是 Meteor 特有的问题,而是 JS 开发人员有时可能会遇到的问题。
对于这个特殊情况,有两个问题:
files字段package.json仅包含src和dist文件夹。这意味着当您通过 npm 获取它时,构建代码所需的几乎所有配置文件都消失了。因为你已经修改了这个包,所以让我们修改package.json如下(删除我添加的所有注释,以便给你一些解释),将其推送到 github,然后通过 npm 再次获取它:
// remove the "files" field
// ...
"scripts": {
// this script is used to build the package
"postinstall": "postinstall-build dist \"npm run build:commonjs\""
// ...
},
"dependencies": {
// this helps build the package
"postinstall-build": "^2.1.3"
},
// ...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
636 次 |
| 最近记录: |