Also, since you're using relative paths, you'd have to change directories to your dist folder to run your server, but it seems like your source code goes up 2 directories, when your dist would only need to go up one (i.e., ../../ should be ../)
Hello Richard, thanks for the answer!
So yes, I go up twice because webpack bundles starting from the src file, and since server.js is contained into server, which is contained into root where the certificate is I have to go up twice so that webpack can import it into dist. As you can see from the error I get the key that fails to be imported is has a / before the filename, which means that it gets imported correctly into the dist folder. However I will try tomorrow to use path.resolve as (I hope at least) it might help! So thanks for the tip!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
In the part where you readFileSync, I would use
path.resolve
. Same for the part withpath.join
.Also, since you're using relative paths, you'd have to change directories to your dist folder to run your server, but it seems like your source code goes up 2 directories, when your dist would only need to go up one (i.e.,
../../
should be../
)If possible, it may be helpful to use aliases to help with path resolution. See more examples here: webpack.js.org/configuration/resolve/
Hello Richard, thanks for the answer!
So yes, I go up twice because webpack bundles starting from the src file, and since server.js is contained into server, which is contained into root where the certificate is I have to go up twice so that webpack can import it into dist. As you can see from the error I get the key that fails to be imported is has a / before the filename, which means that it gets imported correctly into the dist folder. However I will try tomorrow to use path.resolve as (I hope at least) it might help! So thanks for the tip!