I am attempting to add a GUI to a small project of mine using Conrod. I have managed to work my way down to 3 compilation errors:
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:88:53
|
88 | pub fn next(&mut self, events_loop: &mut glium::glutin::EventsLoop) -> Vec<glium::glutin::Event> {
| ^^^^^^ Could not find `glutin` in `glium`
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:88:87
|
88 | pub fn next(&mut self, events_loop: &mut glium::glutin::EventsLoop) -> Vec<glium::glutin::Event> {
| ^^^^^^ Could not find `glutin` in `glium`
error[E0433]: failed to resolve. Could not find `glutin` in `glium`
--> src/support/mod.rs:106:24
|
106 | glium::glutin::ControlFlow::Break
| ^^^^^^ Could not find `glutin` in `glium`
I've studied the examples that ship with Conrod (particularly the text_edit.rs example) and have successfully compiled and run them. As far as I can tell, they use the same techniques (as my code is directly inspired by their examples), yet does not suffer from the unresolved imports of glutin.
Furthermore, I cannot seem to find any reference to glutin in the project directory itself:
$> pwd
~/dev/conrod/src
$> tree.
.
├── backend
│ ├── gfx.rs
│ ├── glium.rs
│ ├── mod.rs
│ ├── piston
│ │ ├── draw.rs
│ │ ├── event.rs
│ │ └── mod.rs
│ └── winit.rs
├── border.rs
├── color.rs
├── cursor.rs
├── event.rs
├── graph
│ ├── algo.rs
│ ├── depth_order.rs
│ └── mod.rs
├── guide
│ ├── chapter_1.rs
│ ├── chapter_2.rs
│ └── mod.rs
├── image.rs
├── input
│ ├── global.rs
│ ├── mod.rs
│ ├── state.rs
│ └── widget.rs
├── label.rs
├── lib.rs
├── position
│ ├── matrix.rs
│ ├── mod.rs
│ ├── range.rs
│ └── rect.rs
├── render.rs
├── tests
│ ├── global_input.rs
│ ├── mod.rs
│ ├── ui.rs
│ └── widget_input.rs
├── text.rs
├── theme.rs
├── ui.rs
├── utils.rs
└── widget
├── bordered_rectangle.rs
├── builder.rs
├── button.rs
├── canvas.rs
├── collapsible_area.rs
├── drop_down_list.rs
├── envelope_editor.rs
├── file_navigator
│ ├── directory_view.rs
│ └── mod.rs
├── graph
│ ├── mod.rs
│ └── node.rs
├── grid.rs
├── id.rs
├── list.rs
├── list_select.rs
├── matrix.rs
├── mod.rs
├── number_dialer.rs
├── plot_path.rs
├── primitive
│ ├── image.rs
│ ├── line.rs
│ ├── mod.rs
│ ├── point_path.rs
│ ├── shape
│ │ ├── circle.rs
│ │ ├── mod.rs
│ │ ├── oval.rs
│ │ ├── polygon.rs
│ │ ├── rectangle.rs
│ │ └── triangles.rs
│ └── text.rs
├── range_slider.rs
├── rounded_rectangle.rs
├── scrollbar.rs
├── scroll.rs
├── slider.rs
├── tabs.rs
├── text_box.rs
├── text_edit.rs
├── title_bar.rs
├── toggle.rs
└── xy_pad.rs
For reference, my Cargo.toml also includes glutin as a dependency:
[features]
default = ["winit", "glium"]
winit = ["conrod/winit"]
glium = ["conrod/glium"]
[dependencies]
conrod = "^0.57"
find_folder = "*"
glutin = "*"
I believe this is a misconception about the module structure of conrod and glium.
The conrod crate has a number of backend modules, containing utility functions for each of the different backends. conrod::backend::glium is this module for glium, and it contains structures and things useful for using conrod with glium.
In your case, however, I think you mistook this module for glium itself.
glium is a separate crate from conrod, and you'll need to depend on it much like you depend on glutin. glium does indeed have a glium::conrod property, so if you do pull it in with extern crate glium; rather than using conrod::backend::glium, it should "just work"!
You'll need to add some line glium = 0.x in your Cargo.toml as well, but that should be trivial.
Related
I am trying to call a method from a rust crate and getting an error stating that a trait is not implemented for one of the methods I am passing however when I look the method up on docs.rs it does appear to be implementing the required trait.
I am trying to call a method called new_with_count from a crate called wagyu_ethereum.
The code I am using to make the call is here:
use rand::{rngs::StdRng, SeedableRng};
use wagyu_ethereum::*;
use wagyu_model::mnemonic::MnemonicCount;
use wagyu_model::MnemonicError;
pub fn generate_mnemonic() -> Result<String, MnemonicError> {
let mut rng = StdRng::from_entropy();
let mnemonic = EthereumMnemonic::<
wagyu_ethereum::network::Mainnet,
wagyu_ethereum::wordlist::English,
>::new_with_count(&mut rng, 24)?;
Ok(String::from("placeholder"))
}
The code for the method (from the projects GitHub page:
impl<N: EthereumNetwork, W: EthereumWordlist> MnemonicCount for EthereumMnemonic<N, W> {
/// Returns a new mnemonic given the word count.
fn new_with_count<R: Rng>(rng: &mut R, word_count: u8) -> Result<Self, MnemonicError> {
let length: usize = match word_count {
12 => 16,
15 => 20,
18 => 24,
21 => 28,
24 => 32,
wc => return Err(MnemonicError::InvalidWordCount(wc)),
};
let entropy: [u8; 32] = rng.gen();
Ok(Self {
entropy: entropy[0..length].to_vec(),
_network: PhantomData,
_wordlist: PhantomData,
})
}
}
The error:
error[E0277]: the trait bound `StdRng: rand_core::RngCore` is not satisfied
--> src/lib.rs:12:23
|
9 | let mnemonic = EthereumMnemonic::<
| ____________________-
10 | | wagyu_ethereum::network::Mainnet,
11 | | wagyu_ethereum::wordlist::English,
12 | | >::new_with_count(&mut rng, 24)?;
| | - ^^^^^^^^ the trait `rand_core::RngCore` is not implemented for `StdRng`
| |_____________________|
| required by a bound introduced by this call
|
= help: the following other types implement trait `rand_core::RngCore`:
&'a mut R
Box<R>
rand::rngs::adapter::read::ReadRng<R>
rand::rngs::adapter::reseeding::ReseedingRng<R, Rsdr>
rand::rngs::entropy::EntropyRng
rand::rngs::mock::StepRng
rand::rngs::std::StdRng
rand::rngs::thread::ThreadRng
and 6 others
= note: required because of the requirements on the impl of `rand::Rng` for `StdRng`
note: required by a bound in `new_with_count`
--> /home/me/.cargo/registry/src/github.com-1ecc6299db9ec823/wagyu-model-0.6.3/src/mnemonic.rs:44:26
|
44 | fn new_with_count<R: Rng>(rng: &mut R, word_count: u8) -> Result<Self, MnemonicError>;
| ^^^ required by this bound in `new_with_count`
So as far as I can tell from the documentation on docs.rs it appears that StdRng does actually implement RngCore. I've also found this question that indicates I might be borrowing to many time but I'm not sure if it is relevant here because I don't think I am borrowing as many times.
Finally on the projects Github account they have instances of calling the method the same way I am doing (method call, rng assignment). This is what prompted me to use this method. Their program also works when you run it. So the question I have is what am I doing wrong when trying to call this method?
At the time of writing, the newest versions are:
rand = "0.8.5"
wagyu-ethereum = "0.6.3"
wagyu-model = "0.6.3"
It seems that a version mismatch exists here. wagyu-ethereum = "0.6.3" depends on rand = "0.7.3", while the current default if you do cargo add rand is rand = "0.8.5".
You can see this in cargo tree:
rust_test v0.1.0 (/home/me/work/rust_test)
├── rand v0.8.5
│ ├── libc v0.2.139
│ ├── rand_chacha v0.3.1
│ │ ├── ppv-lite86 v0.2.17
│ │ └── rand_core v0.6.4
│ │ └── getrandom v0.2.8
│ │ ├── cfg-if v1.0.0
│ │ └── libc v0.2.139
│ └── rand_core v0.6.4 (*)
├── wagyu-ethereum v0.6.3
│ ├── base58 v0.1.0
│ ├── bitvec v0.17.4
│ │ ├── either v1.8.0
│ │ └── radium v0.3.0
│ ├── ethereum-types v0.9.2
│ │ ├── ethbloom v0.9.2
│ │ │ ├── crunchy v0.2.2
│ │ │ ├── fixed-hash v0.6.1
│ │ │ │ ├── byteorder v1.4.3
│ │ │ │ ├── rand v0.7.3
│ │ │ │ │ ├── getrandom v0.1.16
│ │ │ │ │ │ ├── cfg-if v1.0.0
│ │ │ │ │ │ └── libc v0.2.139
│ │ │ │ │ ├── libc v0.2.139
│ │ │ │ │ ├── rand_chacha v0.2.2
│ │ │ │ │ │ ├── ppv-lite86 v0.2.17
│ │ │ │ │ │ └── rand_core v0.5.1
│ │ │ │ │ │ └── getrandom v0.1.16 (*)
│ │ │ │ │ └── rand_core v0.5.1 (*)
│ │ │ │ ├── rustc-hex v2.1.0
│ │ │ │ └── static_assertions v1.1.0
│ │ │ ├── impl-rlp v0.2.1
│ │ │ │ └── rlp v0.4.6
│ │ │ │ └── rustc-hex v2.1.0
│ │ │ ├── impl-serde v0.3.2
│ │ │ │ └── serde v1.0.152
│ │ │ │ └── serde_derive v1.0.152 (proc-macro)
│ │ │ │ ├── proc-macro2 v1.0.49
│ │ │ │ │ └── unicode-ident v1.0.6
│ │ │ │ ├── quote v1.0.23
│ │ │ │ │ └── proc-macro2 v1.0.49 (*)
│ │ │ │ └── syn v1.0.107
│ │ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ │ ├── quote v1.0.23 (*)
│ │ │ │ └── unicode-ident v1.0.6
│ │ │ └── tiny-keccak v2.0.2
│ │ │ └── crunchy v0.2.2
│ │ ├── fixed-hash v0.6.1 (*)
│ │ ├── impl-rlp v0.2.1 (*)
│ │ ├── impl-serde v0.3.2 (*)
│ │ ├── primitive-types v0.7.3
│ │ │ ├── fixed-hash v0.6.1 (*)
│ │ │ ├── impl-codec v0.4.2
│ │ │ │ └── parity-scale-codec v1.3.7
│ │ │ │ ├── arrayvec v0.5.2
│ │ │ │ ├── bitvec v0.17.4 (*)
│ │ │ │ ├── byte-slice-cast v0.3.5
│ │ │ │ └── serde v1.0.152 (*)
│ │ │ ├── impl-rlp v0.2.1 (*)
│ │ │ ├── impl-serde v0.3.2 (*)
│ │ │ └── uint v0.8.5
│ │ │ ├── byteorder v1.4.3
│ │ │ ├── crunchy v0.2.2
│ │ │ ├── rustc-hex v2.1.0
│ │ │ └── static_assertions v1.1.0
│ │ └── uint v0.8.5 (*)
│ ├── hex v0.4.3
│ ├── hmac v0.7.1
│ │ ├── crypto-mac v0.7.0
│ │ │ ├── generic-array v0.12.4
│ │ │ │ └── typenum v1.16.0
│ │ │ └── subtle v1.0.0
│ │ └── digest v0.8.1
│ │ └── generic-array v0.12.4 (*)
│ ├── pbkdf2 v0.3.0
│ │ ├── byteorder v1.4.3
│ │ ├── crypto-mac v0.7.0 (*)
│ │ └── rayon v1.6.1
│ │ ├── either v1.8.0
│ │ └── rayon-core v1.10.1
│ │ ├── crossbeam-channel v0.5.6
│ │ │ ├── cfg-if v1.0.0
│ │ │ └── crossbeam-utils v0.8.14
│ │ │ └── cfg-if v1.0.0
│ │ ├── crossbeam-deque v0.8.2
│ │ │ ├── cfg-if v1.0.0
│ │ │ ├── crossbeam-epoch v0.9.13
│ │ │ │ ├── cfg-if v1.0.0
│ │ │ │ ├── crossbeam-utils v0.8.14 (*)
│ │ │ │ ├── memoffset v0.7.1
│ │ │ │ │ [build-dependencies]
│ │ │ │ │ └── autocfg v1.1.0
│ │ │ │ └── scopeguard v1.1.0
│ │ │ │ [build-dependencies]
│ │ │ │ └── autocfg v1.1.0
│ │ │ └── crossbeam-utils v0.8.14 (*)
│ │ ├── crossbeam-utils v0.8.14 (*)
│ │ └── num_cpus v1.15.0
│ │ └── libc v0.2.139
│ ├── rand v0.7.3 (*)
│ ├── regex v1.7.0
│ │ ├── aho-corasick v0.7.20
│ │ │ └── memchr v2.5.0
│ │ ├── memchr v2.5.0
│ │ └── regex-syntax v0.6.28
│ ├── rlp v0.4.6 (*)
│ ├── secp256k1 v0.17.2
│ │ └── secp256k1-sys v0.1.2
│ │ [build-dependencies]
│ │ └── cc v1.0.41
│ ├── serde v1.0.152 (*)
│ ├── serde_json v1.0.91
│ │ ├── itoa v1.0.5
│ │ ├── ryu v1.0.12
│ │ └── serde v1.0.152 (*)
│ ├── sha2 v0.8.2
│ │ ├── block-buffer v0.7.3
│ │ │ ├── block-padding v0.1.5
│ │ │ │ └── byte-tools v0.3.1
│ │ │ ├── byte-tools v0.3.1
│ │ │ ├── byteorder v1.4.3
│ │ │ └── generic-array v0.12.4 (*)
│ │ ├── digest v0.8.1 (*)
│ │ ├── fake-simd v0.1.2
│ │ └── opaque-debug v0.2.3
│ ├── tiny-keccak v1.5.0
│ │ └── crunchy v0.2.2
│ └── wagyu-model v0.6.3
│ ├── base58 v0.1.0
│ ├── base58-monero v0.2.1
│ │ ├── async-stream v0.2.1
│ │ │ ├── async-stream-impl v0.2.1 (proc-macro)
│ │ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ │ ├── quote v1.0.23 (*)
│ │ │ │ └── syn v1.0.107 (*)
│ │ │ └── futures-core v0.3.25
│ │ ├── futures-util v0.3.25
│ │ │ ├── futures-core v0.3.25
│ │ │ ├── futures-macro v0.3.25 (proc-macro)
│ │ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ │ ├── quote v1.0.23 (*)
│ │ │ │ └── syn v1.0.107 (*)
│ │ │ ├── futures-task v0.3.25
│ │ │ ├── pin-project-lite v0.2.9
│ │ │ ├── pin-utils v0.1.0
│ │ │ └── slab v0.4.7
│ │ │ [build-dependencies]
│ │ │ └── autocfg v1.1.0
│ │ ├── thiserror v1.0.38
│ │ │ └── thiserror-impl v1.0.38 (proc-macro)
│ │ │ ├── proc-macro2 v1.0.49 (*)
│ │ │ ├── quote v1.0.23 (*)
│ │ │ └── syn v1.0.107 (*)
│ │ ├── tiny-keccak v2.0.2 (*)
│ │ └── tokio v0.2.25
│ │ ├── bytes v0.5.6
│ │ ├── futures-core v0.3.25
│ │ ├── memchr v2.5.0
│ │ └── pin-project-lite v0.1.12
│ ├── bech32 v0.6.0
│ ├── byteorder v1.4.3
│ ├── crypto-mac v0.7.0 (*)
│ ├── ethereum-types v0.9.2 (*)
│ ├── failure v0.1.8
│ │ ├── backtrace v0.3.57
│ │ │ ├── addr2line v0.14.1
│ │ │ │ └── gimli v0.23.0
│ │ │ ├── cfg-if v1.0.0
│ │ │ ├── libc v0.2.139
│ │ │ ├── miniz_oxide v0.4.4
│ │ │ │ └── adler v1.0.2
│ │ │ │ [build-dependencies]
│ │ │ │ └── autocfg v1.1.0
│ │ │ ├── object v0.23.0
│ │ │ └── rustc-demangle v0.1.21
│ │ └── failure_derive v0.1.8 (proc-macro)
│ │ ├── proc-macro2 v1.0.49 (*)
│ │ ├── quote v1.0.23 (*)
│ │ ├── syn v1.0.107 (*)
│ │ └── synstructure v0.12.6
│ │ ├── proc-macro2 v1.0.49 (*)
│ │ ├── quote v1.0.23 (*)
│ │ ├── syn v1.0.107 (*)
│ │ └── unicode-xid v0.2.4
│ ├── ff v0.6.0
│ │ ├── byteorder v1.4.3
│ │ └── rand_core v0.5.1 (*)
│ ├── hex v0.4.3
│ ├── rand v0.7.3 (*)
│ ├── rand_core v0.5.1 (*)
│ ├── ripemd160 v0.8.0
│ │ ├── block-buffer v0.7.3 (*)
│ │ ├── digest v0.8.1 (*)
│ │ └── opaque-debug v0.2.3
│ ├── rlp v0.4.6 (*)
│ ├── secp256k1 v0.17.2 (*)
│ ├── serde_json v1.0.91 (*)
│ ├── sha2 v0.8.2 (*)
│ └── uint v0.8.5 (*)
└── wagyu-model v0.6.3 (*)
Usually, Cargo tries to find a single common version of a library for all dependencies, but 0.7.x and 0.8.x are not compatible according to Rust's semver rules, so it includes the library twice. Of course it can't allow those two to be used with each other, as the results would be unpredictable.
While the problem is complicated and obscure, the solution is simple:
Use rand = "0.7.3" in your Cargo.toml until wagyu gets upgraded to rand = "0.8.x".
You could open an issue in their issue-tracker about it, but it seems that the project as a whole didn't get maintained since over a year. Their website doesn't even exist any more. So be aware that this project might be abandoned.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I have a project which is written 3 years ago in reactjs 15 version and also it is single tier architecture project. I am right now converting it to 3 tier project architecture. So I thought of having the react part alone. My question is how should I create a reactJS folder structure using the new create-react-app and add the already existing code into it. I know this question might be broad. But any steps will help me to better understand the structure to be followed in react. Its been like only 2 months I am learning reactjs.
"react": "^15.6.1",
"react-csv": "^1.0.8",
"react-custom-scrollbars": "^4.2.1",
"react-dom": "^15.6.1",
"react-dropzone": "^4.2.3",
"react-flipcard": "^0.2.1",
"react-notification-system": "^0.2.16",
"react-pdf": "^2.4.2",
"react-router": "^3.0.0",
"react-router-dom": "^4.2.2",
"react-stars": "^2.2.5",
"react-table": "^6.7.4",
"react-tabs-navigation": "^0.4.4",
"react-toastr": "^2.8.2",
"semantic-ui-react": "^0.63.5",
"superagent": "^3.8.1",
"universal-cookie": "^2.1.0",
"url-loader": "^4.1.0",
"x-frame-options": "^1.0.0"
I would recommend you to make components folder in src folder. There you can structure components to atoms, molecules, organisms, templates and pages if you are a fan of a Atomic design as I am. From there every component should be separated in separate folder and have component.types.js/ts, component.constants.js/ts, component.scss, component.js/tsx. Types would refer to prop and any other types related to that component. Constants, components and scss file are quite obvious as for what they are used. Also you can have test folder in every component where you can write tests.
Also you can have common folder in src where you can put your utility files, for example custom hooks, http setup etc.
Another important folder in src is config. All config your app needs can be in there in different files if that is needed.
Last but not the least is assests foloder inside src. As name suggests you put all of your static assets (fonts, images, videos...).
I think this is very good basis to start from and expand your folder structure as you see fit and as project is needed. Also none of this i strict to naming but those are some conventions that you can read here.
awesome-app
├── src
│ ├── components
│ │ ├── atoms
│ │ │ ├── button
│ │ │ │ ├── button.types.ts
│ │ │ │ ├── button.component.tsx
│ │ │ │ ├── button.constants.ts
│ │ │ │ ├── button.scss
│ │ │ │ ├── test
│ │ │ │ ├── button.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── molecules
│ │ │ ├── action-card
│ │ │ │ ├── action-card.types.ts
│ │ │ │ ├── action-card.component.tsx
│ │ │ │ ├── action-card.constants.ts
│ │ │ │ ├── action-card.scss
│ │ │ │ ├── test
│ │ │ │ ├── action-card.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── organisms
│ │ │ ├── school-module-row
│ │ │ │ ├── school-module-row.types.ts
│ │ │ │ ├── school-module-row.component.tsx
│ │ │ │ ├── school-module-row.constants.ts
│ │ │ │ ├── school-module-row.scss
│ │ │ │ ├── test
│ │ │ │ ├── school-module-row.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ │ ├── pages
│ │ │ ├── users-page
│ │ │ │ ├── users-page.types.ts
│ │ │ │ ├── users-page.component.tsx
│ │ │ │ ├── users-page.constants.ts
│ │ │ │ ├── users-page.scss
│ │ │ │ ├── test
│ │ │ │ ├── users-page.test.tsx
│ │ │ │ └── ...
│ │ │ └── ...
│ ├── styles
│ │ ├── base
│ │ │ ├── _base.scss
│ │ │ ├── _font.scss
│ │ │ └── ...
│ │ └── ...
│ │
│ ├── assets
│ │ ├── fonts
│ │ │ └── ...
│ │ ├── images
│ │ │ └── ...
│ │ └── ...
│ ├── config
│ │ └── ...
│ └── redux
└── actions
└── ...
This is my configure file:
The layout.jade does not seem to be working. But the jade is working. I used Chrome to check, and am sure that the layout HTML is not loaded into the page.
module.exports = function(app, express, mongoose){
var config=this
app.configure(function (){
app.set('views',__dirname+'/views')
app.set('view engine','jade')
app.set('view options', {layout:true})
app.use(express.bodyParser())
app.use(express.methodOverride())
app.use(express.cookieParser())
app.use(express.session({secret: 'topsecret',store: new express.session.MemoryStore}))
app.use(express.static(app.path.join(app.application_root,"public")))
app.use(express.errorHandler({dumpExceptions:true,showStack:true}))
app.use(express.bodyParser({keepExtensions: true, uploadDir:"./public/uploads"}))
app.use(app.router)
})
/*DB part:*/
app.mongoose.connect('mongodb://localhost/dio_database')
return config
}
The render command:
app.get('/items/:id',function(req,res){
models.ItemModel.findOne({_id:req.params.id}).exec(function(err,item){
if (!err){
res.render('item.jade',item)
} else
return console.log(err)
})
})
My layout.jade, quite simple:
!!!
doctype 5
html
head
title "Dio"
link(rel='icon', href='favicon.ico', type='image/x-icon')
link(rel='shortcut', href='favicon.ico', type='image/x-icon')
link(rel="shortcut", href="favicon.ico", type="image/vnd.microsoft.icon")
link(rel="icon", href="favicon.ico", type="image/vnd.microsoft.icon")
script(src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js")
script(src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js")
script(src="./javascripts/underscore-min.js")
script(src="./javascripts/backbone-min.js")
link(rel='stylesheet', href='./css/main.css', type="text/css", media="screen")
body
div#topbar Dio--where shitty thing happens
div#main!= body
footer
p
| Node.js MVC template by XXX
And the following is my npm list:
├─┬ bcrypt#0.7.3
│ └── bindings#1.0.0
├─┬ express#3.0.3
│ ├── commander#0.6.1
│ ├─┬ connect#2.7.0
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ └── qs#0.5.1
│ ├── cookie#0.0.5
│ ├── cookie-signature#0.0.1
│ ├── crc#0.2.0
│ ├── debug#0.7.0
│ ├── fresh#0.1.0
│ ├── methods#0.0.1
│ ├── mkdirp#0.3.3
│ ├── range-parser#0.0.4
│ └─┬ send#0.1.0
│ └── mime#1.2.6
├── fs#0.0.0
├── imagemagick#0.1.3
├─┬ jade#0.27.7
│ ├── coffee-script#1.4.0
│ ├── commander#0.6.1
│ └── mkdirp#0.3.4
├─┬ mongodb#1.2.2
│ └── bson#0.1.5
├─┬ mongoose#3.4.0
│ ├── hooks#0.2.1
│ ├─┬ mongodb#1.1.11
│ │ └── bson#0.1.5
│ ├── ms#0.1.0
│ └── sliced#0.0.3
├─┬ node-static#0.6.5 extraneous
│ ├── colors#0.6.0-1
│ └─┬ optimist#0.3.5
│ └── wordwrap#0.0.2
└── path#0.4.9
Actually the reason for such problem is quite simple:
Express 3 no longer supports layout..But do not be sad. Actually Express 3 begins to adopt a more natural and easier way, which is called block/extends.
The basic usage should be like this:
// In layout file: layout.jade
html
head
title XXX
block scripts
body
block content
block footer
// in a extended file, for example index.jade:
extends layout
block scripts
//write javascript part
block content
// write content
block footer
// write the footer
It actually becomes easier and more flexible. Glad to get it finally. But it took me more than 2 hours.
I am just wondering why so few people mentioned this change more clearly and openly. Hope this post can help some people like me.
I'm new to NodeJS and trying to build an app over Express3.0, included passport local strategy for authentication purpose. But the following exception(with respect to req.flash) blocks my progress.
Exception occurs in the following line.
res.render('login', { user: req.user, message: req.flash('error') });
Express
500 TypeError: Object # has no method 'flash'
at /Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/app.js:115:54
at callbacks (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:162:37)
at param (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:136:11)
at pass (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:143:5)
at Router._dispatch (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:171:5)
at Object.router (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/lib/router/index.js:33:10)
at next (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/proto.js:190:15)
at store.get.next (/Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/middleware/session.js:310:9)
at /Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/middleware/session.js:333:9
at /Users/vivekanandan/Source/Git/ExpressApp/CosmicEnergyCoupled/node_modules/express/node_modules/connect/lib/middleware/session/memory.js:52:9
I have installed connect-flash to recover the deprecated req.flash method as advised by the author(passport-local-strategy). Please find the npm packages installed in the app.
├── connect-flash#0.1.0
├── ejs#0.8.3
├── ejs-locals#0.2.5
├─┬ express#3.0.0
│ ├── commander#0.6.1
│ ├─┬ connect#2.6.0
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ ├── qs#0.5.1
│ │ └─┬ send#0.0.4
│ │ └── mime#1.2.6
│ ├── cookie#0.0.4
│ ├── crc#0.2.0
│ ├── debug#0.7.0
│ ├── fresh#0.1.0
│ ├── methods#0.0.1
│ ├── mkdirp#0.3.3
│ ├── range-parser#0.0.4
│ └─┬ send#0.1.0
│ └── mime#1.2.6
├─┬ passport#0.1.12
│ └── pkginfo#0.2.3
├─┬ passport-local#0.1.6
│ ├── passport#0.1.12
│ └── pkginfo#0.2.3
├─┬ socket.io#0.9.10
│ ├── policyfile#0.0.4
│ ├── redis#0.7.2
│ └─┬ socket.io-client#0.9.10
│ ├─┬ active-x-obfuscator#0.0.1
│ │ └── zeparser#0.0.5
│ ├── uglify-js#1.2.5
│ ├─┬ ws#0.4.22
│ │ ├── commander#0.6.1
│ │ ├── options#0.0.3
│ │ └── tinycolor#0.0.1
│ └── xmlhttprequest#1.4.2
└─┬ stylus#0.30.1
├── cssom#0.2.5
├── debug#0.7.0
└── mkdirp#0.3.4
Try adding this to your main app.configure method
app.use(flash());
npm install connect-flash --save
var flash = require('connect-flash')
app.use(flash());
You're using it wrong I think. You just have to call req.flash() with type and message before res.redirect
req.flash('info', 'Welcome to the site, a welcome email has been sent to you.');
res.redirect('/');
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
ECONNREFUSED on Port 80
Up until today, my app was working, but then all of a sudden it stopped: it started throwing these errors every time I try to connect to the socket.io-enabled part of the app.
Error: connect ECONNREFUSED
at errnoException (net.js:670:11)
at Object.afterConnect [as oncomplete] (net.js:661:19)
Here are my module version numbers.
CompassionPit#0.5.2 /opt/chat
├── async#0.1.18
├── colors#0.6.0-1
├─┬ connect#2.0.2
│ ├── debug#0.7.0
│ ├── formidable#1.0.9
│ ├── mime#1.2.4
│ └── qs#0.4.2
├── date-utils#1.2.9
├─┬ ecstatic#0.1.6
│ ├── ent#0.0.4
│ └── mime#1.2.5
├─┬ express#2.5.8
│ ├─┬ connect#1.8.7
│ │ ├── formidable#1.0.11
│ │ ├── mime#1.2.5
│ │ └── qs#0.5.0
│ ├── mime#1.2.4
│ ├── mkdirp#0.3.0
│ └── qs#0.4.2
├─┬ flatiron#0.1.17
│ ├─┬ broadway#0.1.15
│ │ ├─┬ cliff#0.1.7
│ │ │ └── eyes#0.1.7
│ │ ├── eventemitter2#0.4.9
│ │ ├─┬ nconf#0.5.1
│ │ │ ├── async#0.1.22
│ │ │ ├── ini#1.0.2
│ │ │ └─┬ optimist#0.3.4
│ │ │ └── wordwrap#0.0.2
│ │ ├─┬ optimist#0.3.1
│ │ │ └── wordwrap#0.0.2
│ │ ├─┬ utile#0.0.10
│ │ │ ├── async#0.1.22
│ │ │ ├── mkdirp#0.3.3
│ │ │ ├── ncp#0.2.6
│ │ │ └── rimraf#1.0.9
│ │ └─┬ winston#0.5.11
│ │ ├── async#0.1.22
│ │ ├── eyes#0.1.7
│ │ ├─┬ loggly#0.3.11
│ │ │ ├── request#2.9.202
│ │ │ └── timespan#2.2.0
│ │ └── stack-trace#0.0.6
│ ├── director#1.0.10
│ ├─┬ optimist#0.3.4
│ │ └── wordwrap#0.0.2
│ ├── pkginfo#0.2.3
│ └─┬ prompt#0.1.12
│ ├── async#0.1.22
│ └─┬ winston#0.5.11
│ ├── async#0.1.22
│ ├── eyes#0.1.7
│ ├─┬ loggly#0.3.11
│ │ ├── request#2.9.202
│ │ └── timespan#2.2.0
│ └── stack-trace#0.0.6
├── geoip#0.4.5
├── hashlib2#1.0.3
├── http-digest#v0.1.0
├─┬ jade#0.20.3
│ ├── commander#0.5.2
│ └── mkdirp#0.3.3
├── marked#0.2.1
├─┬ mongoose#2.5.10
│ ├── hooks#0.2.0
│ └── mongodb#0.9.9-4
├─┬ mysql#0.9.5
│ └─┬ hashish#0.0.4
│ └── traverse#0.6.1
├── nave#0.2.13 extraneous
├─┬ optimist#0.2.8
│ └── wordwrap#0.0.2
├── request#2.1.1
├─┬ socket.io#0.9.0
│ ├── policyfile#0.0.4
│ ├── redis#0.6.7
│ └─┬ socket.io-client#0.9.0
│ ├─┬ ws#0.4.0
│ │ ├── commander#0.5.0
│ │ └── options#0.0.3
│ └── xmlhttprequest#1.2.2
├── sqwish#0.2.0
├── uglify-js#1.2.5
├── underscore#1.3.1
├─┬ union#0.1.8
│ ├── pkginfo#0.2.3
│ └── qs#0.3.2
└─┬ vows#0.5.13
└── eyes#0.1.7
Are you allowing NodeJS to run on port 80? If not you might want to take a look at this: Node.js: ECONNREFUSED on Port 80