简体   繁体   中英

How to use NodeJS global module objects in RequireJS modules

I decided to use RequireJS as my module loader in NodeJS.

Unfortunately, the modules I define don't have access to some of the "global" objects that would be be available if the modules were loaded using the CommonJS method. This includes the objects that are located in the module scope, such as __dirname and __filename .

Is there a relatively simple approach to using these objects in the RequireJS modules?

github( https://github.com/jrburke/requirejs/issues/89 )上的requirejs问题网站上对此进行了介绍,他们似乎建议的解决方法是改用module.uri。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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