react-snap no such file or directory - reactjs

I have an app that works in the following way:
Client bundles are built with webpack and output to /client/app/public/build.
An express server runs from /server/index.js and renders a handlebars template using some environment variables.
After I run yarn run build and the postbuild script is executed, it fails immediately with the following error:
yarn run v1.9.4
$ react-snap
events.js:183
throw er; // Unhandled 'error' event
^
Error: ENOENT: no such file or directory, open '/Users/aington/git/static-help/build/index.html'
error Command failed with exit code 1.
This makes sense, since there are no files in that location.
I know that react-snap prides itself on being a zero-configuration library, but I really would like to configure it so that it can point to the right directory for serving files. Additionally, the Express server provides an authentication library, so that needs to run too.
Is it realistic to expect that react-snap can do this and still crawl and pre-render the site? Or should I explore other options?

Check the default options in index.js
https://github.com/stereobooster/react-snap/blob/97542b802917362773a2601f52d368c01bd5e0f7/index.js#L15
and use it in package.json like the below
"reactSnap" : {
"source" : "./dist"
}

Related

How to specify runtime directory for Vite when running the dev server

I'm trying to use Vite for a React project. I need to configure Vite so that when I run the dev server it places the runtime files in a particular directory (because the files are used with another runtime environment). The server config doesn't seems to have an option but I'm not sure if I'm missing something or it is in a different place. Thanks
It doesn't seem to be possible right now according to this repo discussion https://github.com/vitejs/vite/discussions/6108
Meanwhile, you could run the dev command along with the build --watch command to have both, but it would get slower
npm run dev & npm run build -- --watch

run create-react-app build artifacts as local file not served

I'd like to run a create-react-app (5.0.1) with react (8.0) as a local file. i.e. Not served.
Is this possible?
I've built a basic app and run the build command. Inside the build folder I've opened the html file directly from the browser. I get the following error:
Loading failed for the <script> with source “file:///static/js/main.eb2f7516.js”.
Technically react should be able to do this, right?
If you look at the create-react-app documentation you'll see one suggested method
is to use serve.
A convenient way to test your build is to run the npm run build command, and then run npx serve -s build while in the same folder. This should now serve your static site on port 3000 by default.

Trying to compile React Native app and I am getting an error about React.js not existing

I am trying to compile my first React Native project, and it all works fine from the CLI, until I try to install a new library.
After installing any library, I get various errors, culminating in this:
error: bundling failed: Error: While trying to resolve module `react` from file `/Users/myname/Desktop/Projects/ProjectName/App.js`, the package `/Users/myname/Desktop/Projects/ProjectName/node_modules/react/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/Users/myname/Desktop/Projects/ProjectName/node_modules/react/index.js`. Indeed, none of these files exist:
I have, indeed, confirmed that those files exist.
What is going on here? I'm constantly having these errors as I am trying to use React Native, even when rebuilding the app multiple times and trying over.
Do the following steps:
Stop metro bundler
Delete node_modules folder
cd into your project folder and run:
'npm install'

react-router tutorial not working on mac

I tried to get into react following the react tutorials and got it working, but when I started to go to the next step and use react-router through this tutorial I failed every time!
When I follow the instructions everything seems to be working OK, no errors on terminal, but I don't see any bundle.js files created in my project folder nor the localhost:8080 shows anything other than the following error in console:
GET http://localhost:8080/ net::ERR_EMPTY_RESPONSE
I tried installing npm locally and globally but none worked, same as webpack. Also I tried running the servers using webpack with the code webpack ./index.js bundle.js doesn't work either and throws the following error in terminal:
ERROR in multi main
Module not found: Error: Cannot resolve module 'bundle.js' in /Users/jafari/Desktop/React-Toturial/react-router-tutorial/lessons/01-setting-up
# multi main
While this code creates the bundle.js file and if I run this folder through MAMP on the localhost I can see the desired content of the tutorial, when I change anything in the App.js it doesn't take effect until I remove the bundle.js and do the process I mentioned earlier again in the terminal while still seeing the following error in the console:
bundle.js:49 Uncaught Error: Cannot find module "bundle.js"
And if I don't remove bundle.js I get this error in the console:
Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:(client) <div data-reactid="(server) <div data-reactid="
Any ideas? or alternatively any suggestion or tutorial on how to use react-router?
Try to change the port to something else with the command webpack-dev-server --port 3000 --inline --content-base
You can also substitute the npm start script in the package.json with that line.

goapp deploy - failed parsing input: app file conflicts with same file imported from GOPATH

My GOPATH is set to
d:\Mihai\Programming\Go\
and my project is structured like this
d:\Mihai\Programming\Go\
--> src
-----> code.google.com
-----> tursibservice
File conflict
When I try to deploy like this
cd d:\Kit\go_appengine
goapp deploy -oauth d:\Mihai\Programming\Go\src\tursibservice\
I get the following error
RuntimeError: 2014/09/13 12:52:12 go-app-builder:
Failed parsing input: app file model.go conflicts
with same file imported from GOPATH
If I change the model.go to tursibmodel.go, for example, I get the same error, only now it's complaining that the tursibmodel.go has the conflict.
Successful deployment
When I deploy my app like this
cd d:\Mihai\Programming\Go\src\tursibservice\
d:\Kit\go_appengine\goapp deploy -oauth
I get a Deployment successful and everything works as expected.
So, if I'm deploying from within my app, specifying the goapp's full path, it works, but if I'm deploying from within the go_appengine path, specifing my app's full path, I get an error.
Any idea what's the difference?

Resources