I now learning NodeJS and I want to use Mustache-express as the template engine (I want to use it instead of Pug, because I used it before on FrontEnd and I think it's a really smart and easy template system). I use nodemon to run the NodeJS server and it's work correctly, it restart every time when I change any file, except the views. When I change anything in the view files, I don't seem it in the requests' responses, only when I restart the NodeJS server. What can I do with that?
I already turned out the cache with the following code:
app.disable('etag');
Run nodemon with the command nodemon -e js,html (if the extension of your views is not html, then replace it)
Related
I'm learning about NodeJS, but, the first thing that i noticed is that i need to do a NPM RUN App everytime something is modified in the code.
I read about a package in Node to automatically do it. But i wonder if there is something more simpler
Is there a way to use it like a Laravel app?
Something like, creating a folder in the htdocs and just save it and refresh the webpage to see the changes?
I'm in a big trouble, I'm a really a noob on React and in the company I work on I propose to code a project that was on pure Javascript to update it to ReactJS,
In this project I can't use a node server And I have been coding React without JSX as shown on this page:
https://facebook.github.io/react/docs/react-without-jsx.html
it's working... but as soon as the project gets more complicated, then gets more complicated to code...
I though I have found a solution to work on JSX without a Node server, that is to code with create-react-app:
https://github.com/facebookincubator/create-react-app
I can code on JSX and then run the command "npm run build" and it generates all the React code in the build folder, and then I tried to run build/index.html, but it doesn't load anything, any idea If what I'm trying to do is it possible?
Once you get things working the right way, I highly recommend you use .jsx. You can hook a frontend to any backend you want. Don't you have an existing index.html file that you can import your React entry file into?
create-react-app has its own way of doing things. If you're updating an existing codebase, you should probably be starting from scratch.
You need a server to host your dist/index.html site. This requires you to build a simple server with either node or some other back end programming language. I believe the reason it works whenever you use create-react-app it is because when you npm start create-react-app runs a simple server to host your application. Why can't you use a node server?
So I have a simple Ember.js app which communicates with a node.js server using websockets. The stream server doesn't serve the actual ember app - just various bits of data. Can I have ember-cli automatically re-run my server code when a file is changed inside it?
My workflow is currently
ember s
node ./stream_server/index.js -p 4201
Now I can edit frontend stuff and have everything automatically update. Great! However, if I make a change to my server code, I have to manually go in and C-c it, and re-run node ./stream_server/index.js -p 4201. This gets kind of boring when I know that somewhere in Ember, there's a watcher that's already doing this for frontend stuff.
So, any chance of this working? Or do I just use some other watcher tool to do it?
Cheers,
Carl
I'm currently moving on with reading about node. I'm getting through the tutorials well using the command line. However I am thinking ahead and I want to create a simple register, log in and log out website.
Where would I place the node files on a server (all examples I see run from local host:3000)?
What is the best tutorial for creating this type of website from scratch with node?
Thanks in advance!
It doesn't really matter where you put the files on the server. The localhost:3000 bit comes from the fact that your core server file tells the server to listen on that port.
I would recommend using the express-generator from npm. It's pretty versatile and does a lot of the leg work.
Just run the following:
npm install express-generator
After installing, you'll need to just run the following to create a new web app:
express
The details are here: http://expressjs.com/starter/generator.html.
Also, try to read through and understand all of the pre-provided code.
I have a lot of files in my assets/js directory. At first I thought I was somehow losing the ability to see/serve files from sails. But after I let sails run for a little while, it seems sails found my files in the assets/js directory and I was able to run my intern tests. I'm assuming there is some type of behind the scenes cache going on that must run before I can successfully make a request. Is this the reason, and if so, how can I disable it for a more instant access to my files?
Sails.js needs to do several things before lifting the server, you can try sails lift --verbose to see what's happening.
Also, if you dont mind, take a look the .js files under tasks/config/, Sails.js uses them to link/copy/build assets before starting.