choojs / nanotiming

⏲ - Small timing library
MIT License
35 stars 11 forks source link

Cannot find module 'perf_hooks' from nanotiming #19

Closed kristoferjoseph closed 6 years ago

kristoferjoseph commented 6 years ago

I am running a standalone browserify build that is not completing because of this error. Error: Cannot find module 'perf_hooks' from '.../node_modules/nanotiming' https://github.com/choojs/nanotiming/blob/master/index.js#L6

kristoferjoseph commented 6 years ago

I upgraded to the latest node version 8.9.4 and the error changed to something like Error: lstat perf_hooks is not a file or directory

if i create a file named 'perf_hooks' at the path listed in the error it works as expected :/

kristoferjoseph commented 6 years ago

Looks like wrapping the require('perf_hooks') in a try catch isn't enough. Error causes browserify standalone build to fail Error: Cannot find module 'perf_hooks' from '.../node_modules/nanotiming'

yoshuawuyts commented 6 years ago

Tested this on node 6, 8 and 9 today, and it seems the try...catch should be enough. Is this perhaps related to a bundler you're running on your end perhaps?

goto-bus-stop commented 6 years ago

https://github.com/browserify/browserify/pull/1815 should fix I think?

xiaoanne commented 6 years ago

I got this fixed by upgrade node version to 8.11.2:

nvm install v8.11.2