admin管理员组文章数量:1391947
Getting the following error while doing yarn generate
in production in a Kubernetes container. It is working fine on local. And it was also working fine on production till last week.
Error: Cannot find module 'node:fs'
Require stack:
- /usr/app/node_modules/rc9/dist/index.cjs
- /usr/app/node_modules/@nuxt/config/dist/config.js
- /usr/app/node_modules/@nuxt/cli/dist/cli-index.js
- /usr/app/node_modules/@nuxt/cli/dist/cli.js
- /usr/app/node_modules/nuxt/bin/nuxt.js
I already have the following fix implemented in nuxt.config.js file.
config.node = {
fs: 'empty',
}
VERSIONS
node:14.17.5-alpine
nuxt": ^2.15.8
Thank you for you guidance.
I tried using an upgraded image of Node.js (16.5.0-alpine), but that started giving another error while building.
sass-loader not found
Getting the following error while doing yarn generate
in production in a Kubernetes container. It is working fine on local. And it was also working fine on production till last week.
Error: Cannot find module 'node:fs'
Require stack:
- /usr/app/node_modules/rc9/dist/index.cjs
- /usr/app/node_modules/@nuxt/config/dist/config.js
- /usr/app/node_modules/@nuxt/cli/dist/cli-index.js
- /usr/app/node_modules/@nuxt/cli/dist/cli.js
- /usr/app/node_modules/nuxt/bin/nuxt.js
I already have the following fix implemented in nuxt.config.js file.
config.node = {
fs: 'empty',
}
VERSIONS
node:14.17.5-alpine
nuxt": ^2.15.8
Thank you for you guidance.
I tried using an upgraded image of Node.js (16.5.0-alpine), but that started giving another error while building.
sass-loader not found
Share
Improve this question
edited Feb 9, 2023 at 19:21
Syed Faris Ahmed
asked Feb 9, 2023 at 19:19
Syed Faris AhmedSyed Faris Ahmed
1121 gold badge1 silver badge8 bronze badges
4
- It seems that you are facing two different issues. The first issue with the error message "Cannot find module 'node:fs'" is related to the missing 'fs' module in your Node.js environment. The solution you mentioned in your nuxt.config.js file is the correct approach to handle this error by setting the fs property to 'empty'. Regarding the second issue with the error message "sass-loader not found," it indicates that the sass-loader module is not installed in your environment. This issue can be resolved by installing the missing package by running the following mand: yarn add sass-loader – Bouramas Commented Feb 10, 2023 at 7:05
- If you are still facing issues, I would remend checking if all the required dependencies are installed and present in your node_modules directory. You can do this by checking the dependencies section of your package.json file and running yarn install to install any missing dependencies. – Bouramas Commented Feb 10, 2023 at 7:05
- Hi @Bouramas, thanks for responding. Second issue is only ing if I upgrade node to version 16.x.x But I want to keep Node to version 14.x.x. And even after applying the fs: empty fix. it is still causing the "Cannot find module node:fs" error – Syed Faris Ahmed Commented Feb 10, 2023 at 9:43
-
fs: 'empty'
doesn't work for me, I have to upgrade nodejs to 18.16.0. – Capt. Michael Commented Jun 13, 2023 at 16:01
3 Answers
Reset to default 2I had the exact same problem with nuxtjs and solved it like this way:
- I tried to update my nodeJs to the last stable version:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Based on this: How can I update my nodeJS to the latest version?
- Then, I've done this:
export NODE_OPTIONS=--openssl-legacy-provider
Based on this error : https://github./webpack/webpack/issues/14532#issuement-947012063
However, I can't really understand why it worked, if someone could edit and give more details.
I had the similar error on a fresh nuxt.js project, solved by upgrading the node version to 16.13.1
sudo apt install curl
curl https://raw.githubusercontent./creationix/nvm/master/install.sh | bash
source ~/.profile
nvm install 16.13.1
nvm use 16.13.1
I had similar error with Nuxt 2 production build when updating NodeJS version and I solve it by upgrade nuxt-start package:
yarn add nuxt-start
本文标签: javascriptNUXT Cannot find module nodefsStack Overflow
版权声明:本文标题:javascript - NUXT: Cannot find module node:fs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744669689a2618750.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论