简体   繁体   English

导入直接从github安装的npm模块

[英]Import npm module installed directly from github

There is an npm package that I want to use in my Meteor app. 我想在我的Meteor应用程序中使用npm包 It was missing some features so I forked the repo and applied the patch myself. 它缺少一些功能所以我分叉了回购并自己应用了补丁。 I installed the forked package using: 我使用以下方法安装了forked包:

meteor npm install --save https://github.com/suheb/react-slick.git

Now when I try to use the package using import Slider from 'react-slick' , I get the following error: 现在当我尝试使用import Slider from 'react-slick'来使用包时,我收到以下错误:

Uncaught Error: Cannot find module 'react-slick' install.js:101

How can I use this package installed directly from github? 如何直接从github安装这个软件包?

PS: I have asked the original owner to update the package on npm registry but I'm not sure long it'll take. PS:我已经要求原主人更新npm注册表中的包,但我不确定它会花多长时间。

The package you want to install needs to be compiled by Babel before you can use it. 您要安装的软件包需要先由Babel编译才能使用它。 GitHub repo contains only source code, not compiled JS. GitHub repo只包含源代码,不包含JS编译。 As @noah suggested, what is published to the NPM registry is compiled code (the result of running prepublish script defined in package.json ). 正如@noah建议的那样,发布到NPM注册表的是编译代码(在package.json定义的运行prepublish脚本的结果)。

Currently you are not able to install this kind of packages directly from a Git repository - the issue in NPM command line client that prevents it is tracked here: https://github.com/npm/npm/issues/3055 目前您无法直接从Git存储库安装此类软件包 - NPM命令行客户端中阻止它的问题在此处进行跟踪: https//github.com/npm/npm/issues/3055

Please consider using this helper script (authored by me): https://github.com/lzrski/npm-git-install/ 请考虑使用这个帮助程序脚本(由我编写): https//github.com/lzrski/npm-git-install/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM