how to require from URL in Node.js

前端 未结 6 2426
一个人的身影
一个人的身影 2020-11-28 07:54

Is there a standard way to require a Node module located at some URL (not on the local filesystem)?

Something like:

require(\'http://example.com/node         


        
6条回答
  •  执念已碎
    2020-11-28 08:33

    Install the module first :

    npm install require-from-url
    

    And then put in your file :

    var requireFromUrl = require('require-from-url/sync');
    requireFromUrl("http://example.com/nodejsmodules/myModule.js");
    

提交回复
热议问题