nw.js icon indicating copy to clipboard operation
nw.js copied to clipboard

Node modules not loading, "require" function not working

Open dperu opened this issue 11 years ago • 7 comments

The following code works with nwjs-v0.12.3-win-x64 but it does not work in nwjs-v0.13.0-alpha2-win-x64 on my computer. I am currently using NodeJS v0.12.7.

<html> <body> <script> // get the system platform using node.js var os = require('os') document.write('Our computer is: ', os.platform()) </script> </body> </html>

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

dperu avatar Oct 06 '15 14:10 dperu

nwjs v0.13.0 is reworking some things to take advantage of / better fit with newer chromium/v8 versions. Some of the global variables that were always "just there" in nw.js 0.12 are now contained within the global variable 'nw'. Using 'nw.require' should work.

Please check some of the other times people have asked the same question, such as:#3837 #3765 and look at the mail group postings. nw.js v0.13.0 is the experimental in-progress alpha wow-some-things-work with new v8/Chromium version. :smile:

tshinnic avatar Oct 06 '15 22:10 tshinnic

RE: "Please check some of the other times people have asked the same question"

I did try to search for it but there was no error message or exception. The code snippet worked in one release but not the other. My searches did not show any results you cited. And here I thought I was being a good ciitizen by pointing out an issue.

dperu avatar Oct 13 '15 13:10 dperu

The following code DOES work with nwjs-v0.13.0-alpha2-win-x64 on my computer:

<html> <body> <script> // get the system platform using node.js var os = nw.require('os') document.write('Our computer is: ', os.platform()) </script> </body> </html>

The doc on the following page should probably be updated to show this change: https://github.com/nwjs/nw.js

dperu avatar Oct 13 '15 13:10 dperu

@dperu Missing old questions/issues happens. I just found where a report I generated last week against Chrome actually had 9 (!) duplicates across a year and a half time. I just don't know how I missed seeing _all_ of them.... :/

tshinnic avatar Oct 21 '15 19:10 tshinnic

The following codes work fine for me on nwjs-sdk-v0.24.4.

<html>
<body>
<script>
// get the system platform using node.js
var os = require('os')
document.write('Our computer is: ', os.platform())
</script>
</body>
</html>

Christywl avatar Sep 05 '17 02:09 Christywl

close until there is more information.

Christywl avatar Oct 10 '17 06:10 Christywl

Hi does this thing work in browser?

like i wanted to use this in reactjs web application. will it work

lakshmajee avatar Feb 10 '21 18:02 lakshmajee