admin管理员组文章数量:1418669
I got the following error when creating a site with react-static create mand:
Error: Cannot find module 'perf_hooks'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/react-static/lib/utils/index.js:45:19)
Just installed react-static using npm.
I got the following error when creating a site with react-static create mand:
Error: Cannot find module 'perf_hooks'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/react-static/lib/utils/index.js:45:19)
Just installed react-static using npm.
Share Improve this question asked Mar 2, 2019 at 12:26 MiguelSlvMiguelSlv 15.2k19 gold badges111 silver badges186 bronze badges2 Answers
Reset to default 2perf_hooks
is available since nodejs v8.5.
Check your nodejs version by node -v
.
My code had:
if (typeof performance === 'undefined') {
// Older Node.js
globals.performance = require('perf_hooks').performance;
} else {
// Browser.
globals.performance = performance;
}
to work around: https://github./nodejs/node/issues/28635 that hadn't been solved.
Since in that case the browser is taken care of trivially by the exposed global, I just hacked it to:
globals.performance = eval('require')('perf_hooks').performance;
which makes webpack incapable of seeing the dependency as desired, as mentioned at: How can I make webpack skip a require
Tested on react-scripts 4.0.3.
本文标签: javascriptError Cannot find module 39perfhooks39 when creating site with ReactstaticStack Overflow
版权声明:本文标题:javascript - Error Cannot find module 'perf_hooks' when creating site with React-static - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745294359a2651985.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论