点错误!尝试使用 dotenv,但收到有关多个“缺少模块”的错误;
我需要在 React 项目中使用环境因素,但是每当我尝试使用 dotenv 时,我都会收到一堆“找不到模块”错误。我什至尝试安装这些错误中提到的每个模块,但这并不重要。我仍然遇到同样的错误,这令人沮丧。我尝试过卸载&重新安装 dotenv,我尝试安装每个所谓的“缺失模型”,但这并不重要,当我在代码“require('dotenv').config() 中使用这一行时,我仍然遇到同样的该死的错误;”。我不知道为什么运行起来如此复杂;为什么有这么多依赖关系,这让我作为一个程序员感到极其不足:(
ERROR in ./node_modules/dotenv/lib/main.js 1:11-24
Module not found: Error: Can't resolve 'fs' in '/Users/tazar/nft-minter-tutorial-idk/minter-starter-files/node_modules/dotenv/lib'
@ ./src/util/pinata.js 3:0-24
@ ./src/util/stopbeingadick.js 4:0-44
@ ./src/Minter.js 8:0-81 58:14-39 65:33-46
@ ./src/App.js 5:0-30 11:35-41
@ ./src/index.js 7:0-24 11:33-36
ERROR in ./node_modules/dotenv/lib/main.js 3:13-28
Module not found: Error: Can't resolve 'path' in '/Users/tazar/nft-minter-tutorial-idk/minter-starter-files/node_modules/dotenv/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
@ ./src/util/pinata.js 3:0-24
@ ./src/util/stopbeingadick.js 4:0-44
@ ./src/Minter.js 8:0-81 58:14-39 65:33-46
@ ./src/App.js 5:0-30 11:35-41
@ ./src/index.js 7:0-24 11:33-36
ERROR in ./node_modules/dotenv/lib/main.js 5:11-24
Module not found: Error: Can't resolve 'os' in '/Users/tazar/nft-minter-tutorial-idk/minter-starter-files/node_modules/dotenv/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "os": false }
@ ./src/util/pinata.js 3:0-24
@ ./src/util/stopbeingadick.js 4:0-44
@ ./src/Minter.js 8:0-81 58:14-39 65:33-46
@ ./src/App.js 5:0-30 11:35-41
@ ./src/index.js 7:0-24 11:33-36
3 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.69.1 compiled with 3 errors and 1 warning in 21 ms
I need to use environmental factors for a react project, but whenever I try to use dotenv, I receive A BUNCH of 'module not found' errors. I even tried to install every module that is mentioned in these errors, but it doesn't matter. I still get the same damn errors, it's frustrating. I've tried uninstalling & reinstalling dotenv, and I've tried installing every so-called 'missing model' but it doesn't matter, I still get the same damn errors when I use this line in my code "require('dotenv').config();". I don't know why it's so complicated to run & why there are so many dependencies, it makes me feel extremely inadequate as a programmer :(
ERROR in ./node_modules/dotenv/lib/main.js 1:11-24
Module not found: Error: Can't resolve 'fs' in '/Users/tazar/nft-minter-tutorial-idk/minter-starter-files/node_modules/dotenv/lib'
@ ./src/util/pinata.js 3:0-24
@ ./src/util/stopbeingadick.js 4:0-44
@ ./src/Minter.js 8:0-81 58:14-39 65:33-46
@ ./src/App.js 5:0-30 11:35-41
@ ./src/index.js 7:0-24 11:33-36
ERROR in ./node_modules/dotenv/lib/main.js 3:13-28
Module not found: Error: Can't resolve 'path' in '/Users/tazar/nft-minter-tutorial-idk/minter-starter-files/node_modules/dotenv/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "path": false }
@ ./src/util/pinata.js 3:0-24
@ ./src/util/stopbeingadick.js 4:0-44
@ ./src/Minter.js 8:0-81 58:14-39 65:33-46
@ ./src/App.js 5:0-30 11:35-41
@ ./src/index.js 7:0-24 11:33-36
ERROR in ./node_modules/dotenv/lib/main.js 5:11-24
Module not found: Error: Can't resolve 'os' in '/Users/tazar/nft-minter-tutorial-idk/minter-starter-files/node_modules/dotenv/lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "os": false }
@ ./src/util/pinata.js 3:0-24
@ ./src/util/stopbeingadick.js 4:0-44
@ ./src/Minter.js 8:0-81 58:14-39 65:33-46
@ ./src/App.js 5:0-30 11:35-41
@ ./src/index.js 7:0-24 11:33-36
3 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.
webpack 5.69.1 compiled with 3 errors and 1 warning in 21 ms
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论