fs dependency not found

s-ferdie
0
s-ferdie
commented 9 months ago

I've follow the instructions to add the dotenv module.
When I run npm run dev I'm getting the following error:

This dependency was not found:

  • fs in ./node_modules/@nuxtjs/dotenv/dist/index.js

To install it, you can run: npm install --save fs

Digging into this npm package its seems to be a security-holder package.
How to solve the error?

0
tobiasfrei
0
tobiasfrei
commented 9 months ago

same issuse here for fs '0.0.1-security':

`This dependency was not found:

  • fs in ./modules/read-dir.js

To install it, you can run: npm install --save fs
Server listening on http://127.0.0.1:3000`

node 8.9.4
npm 5.7.1

0
JulienTant
245
JulienTant
commented 9 months ago

Can you guys help me reproduce this ? I've just tried with npm & yarn, I just can't reproduce :(

0
phikhi
5
phikhi
commented 8 months ago

@s-ferdie @tobiasfrei

You could try updating node.

I had that issue a while ago. Not in a nuxt project, but in a classic webpack app.
I found that trick somewhere on github that worked for me.

So try adding a config.node object inside the build.extend function of your nuxt.config.js :

build: {
    extend (config, { isDev, isClient }) {

       config.node: {
            fs: 'empty'
        }

       // ....
    }
}

After that if you get the same error, but for other dependencies, like net or tls. You can add them as well in the same config.node

1
JulienTant
245
JulienTant
commented 8 months ago

@phikhi thank you so much for helping on this! ❤️

1
JulienTant
245
JulienTant
commented 8 months ago

If you need more help about that, please reopen.

0
kayyyy
0
kayyyy
commented 5 months ago

I solved this because i added dotenv to the devDependencies instead of to the dependencies.

0
nicroto
5
nicroto
commented 4 months ago

The snippet above is not syntactically correct. To save someone some time, here it is (of course the ... are also not syntactically correct, they're just there to guide you where you place this):

// nuxt.config.js

export default {

    ...

    build: {

        ...

        extend: function (config, {isDev, isClient}) {

            config.node = {

                fs: "empty"
            };
        }
    },

    ...
};
0
phikhi
5
phikhi
commented 4 months ago

@nicroto

The snippet above is not syntactically correct.

Why ?

0
ValdoGhafoor
0
ValdoGhafoor
commented 4 months ago

@phikhi Because you wrote
config.node: {
while correct syntax would be
config.node = {

0
ktiedt
0
ktiedt
commented a month ago

Seeing this same error with latest Node LTS + Nuxt 2.20 and the above mentioned config change does not fix it.

0
Informations
QuestionUnresolved
#c11 - Created 9 months ago