最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - How is the right way of adding a custom hls dependency to my react node project? - Stack Overflow

programmeradmin1浏览0评论

I want to modify the sources from .js and add it to my project.

I downloaded .js sources, made a few changes and ran npm run build. Then i took the hls.js file from the /dist dir, and tried to add it to my react node project. Created a "local_modules" dir in in the root folder of the project and pasted the hls.js file there. Then added in package.json the dependency: "hls.js": "file:/local_modules/hls.js" and ran npm install. From my react component i imported: import Hls from "hls.js"; And i keep getting the error module not found.

If i place the hls.js file in a folder inside src and import Hls from there it kind of works with several errors.

What is the right way of doing this?

I want to modify the sources from https://github/video-dev/hls.js and add it to my project.

I downloaded https://github/video-dev/hls.js sources, made a few changes and ran npm run build. Then i took the hls.js file from the /dist dir, and tried to add it to my react node project. Created a "local_modules" dir in in the root folder of the project and pasted the hls.js file there. Then added in package.json the dependency: "hls.js": "file:/local_modules/hls.js" and ran npm install. From my react component i imported: import Hls from "hls.js"; And i keep getting the error module not found.

If i place the hls.js file in a folder inside src and import Hls from there it kind of works with several errors.

What is the right way of doing this?

Share Improve this question asked Mar 19 at 16:11 rainwizrainwiz 1
Add a comment  | 

1 Answer 1

Reset to default -1

If you are putting the file in a directory inside your project, then it isn't a dependency. It is part of your project. It shouldn't be recorded as a dependency.

If you wanted to use it as a dependency, then you'd need to state the location of the project you are importing from.

"hls.js": "file:///Users/Bob/projects/hls.js"
发布评论

评论列表(0)

  1. 暂无评论