Issue running Ionic commands in PowerShell - node.js

When I try to run an ionic command in PowerShell I get an error that says
ionic : The term 'ionic' is not recognized as the name of a cmdlet, function, script file, or operable program. Check
the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ ionic
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (ionic:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Does anyone know how I can fix this? Do I need to add a path variable to my environment variables?
I have installed node.js successfully and I believe have successfully installed Ionic and Cordova as well with the command "npm install -g ionic cordova"
The output from the "npm install -g ionic" is below
C:\Users\username\AppData\Roaming\npm\ionic -> C:\Users\username\AppData\Roaming\npm\node_modules\ionic\bin\ionic
ionic#1.3.20 C:\Users\username\AppData\Roaming\npm\node_modules\ionic
├── proxy-middleware#0.7.0
├── connect-livereload#0.5.2
├── progress#1.1.7
├── open#0.0.5
├── colors#0.6.2
├── ncp#0.4.2
├── underscore#1.7.0
├── crc#3.2.1
├── async#0.9.0
├── q#1.0.1
├── semver#4.3.1
├── shelljs#0.2.6
├── cross-spawn#0.2.3 (lru-cache#2.5.0)
├── cli-table#0.3.1 (colors#1.0.3)
├── event-stream#3.0.20 (stream-combiner#0.0.4, duplexer#0.1.1, from#0.1.3, map-stream#0.0.5, pause-stream#0.0.11, split
#0.2.10, through#2.3.6)
├── finalhandler#0.2.0 (escape-html#1.0.1, debug#2.0.0)
├── form-data#0.1.4 (mime#1.2.11, combined-stream#0.0.7)
├── optimist#0.6.0 (wordwrap#0.0.2, minimist#0.0.10)
├── connect#3.1.1 (utils-merge#1.0.0, parseurl#1.3.0, debug#1.0.4, finalhandler#0.1.0)
├── opbeat-ionic#1.1.3 (json-stringify-safe#5.0.0, console-log-level#1.0.0, stackman#0.2.2, after-all#2.0.1)
├── npm#2.1.3
├── tiny-lr-fork#0.0.5 (debug#0.7.4, qs#0.5.6, faye-websocket#0.4.4, noptify#0.0.3)
├── serve-static#1.7.1 (escape-html#1.0.1, utils-merge#1.0.0, parseurl#1.3.0, send#0.10.1)
├── xml2js#0.4.4 (sax#0.6.1, xmlbuilder#2.6.2)
├── unzip#0.1.9 (setimmediate#1.0.2, readable-stream#1.0.33, pullstream#0.4.1, match-stream#0.0.2, binary#0.3.0, fstream
#0.1.31)
├── prompt#0.2.12 (revalidator#0.1.8, pkginfo#0.3.0, read#1.0.5, winston#0.6.2, utile#0.2.1)
├── request#2.51.0 (json-stringify-safe#5.0.0, caseless#0.8.0, forever-agent#0.5.2, aws-sign2#0.5.0, stringstream#0.0.4,
tunnel-agent#0.4.0, oauth-sign#0.5.0, node-uuid#1.4.3, qs#2.3.3, mime-types#1.0.2, combined-stream#0.0.7, tough-cookie#
0.12.1, bl#0.9.4, http-signature#0.10.1, form-data#0.2.0, hawk#1.1.1)
├── vinyl-fs#0.3.7 (graceful-fs#3.0.6, lodash#2.4.1, strip-bom#1.0.0, vinyl#0.4.6, mkdirp#0.5.0, through2#0.6.3, glob-st
ream#3.1.18, glob-watcher#0.0.6)
├── archiver#0.5.1 (lodash#2.4.1, readable-stream#1.1.13, lazystream#0.1.0, zip-stream#0.1.4, file-utils#0.1.5)
└── gulp#3.8.8 (pretty-hrtime#0.2.2, interpret#0.3.10, deprecated#0.0.1, archy#0.0.2, minimist#1.1.1, semver#3.0.1, tild
ify#1.0.0, chalk#0.5.1, orchestrator#0.3.7, gulp-util#3.0.4, liftoff#0.12.1)

I figured out my mistake. I was missing a path variable to system32. Thanks for the help!

Related

Cannot find `glutin` in `glium` when using Conrod

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.

Error Phonegap App with Mobile Angular Ui

I'm following this guide
http://mobileangularui.com/blog/your-first-phonegap-app-with-mobile-angular-ui/#why-not-just-twitter-bootstrap-and-angular-ui-
but when i run this code
npm install -g bower yo gulp generator-mobileangularui
I receive this error...
C:\Users\Desktop\Sorgente\weather>npm install -g bower yo gulp
generator-mobileangularui
> npm WARN engine yo#1.4.6: wanted: {"node":">=0.10.0","npm":">=2.1.0"}
(current:
{"node":"v0.10.29","npm":"1.4.14"})
|
> buffertools#2.1.2 install C:\Users\AppData\Roaming\npm\node_m
odules\generator-mobileangularui\node_modules\slug\node_modules\unicode\node_mod
ules\bufferstream\node_modules\buffertools
> node-gyp rebuild
C:\Users\AppData\Roaming\npm\node_modules\generator-mobileangul
arui\node_modules\slug\node_modules\unicode\node_modules\bufferstream\node_modul
es\buffertools>node "C:\Program Files\nodejs\node_modules\npm\bin\node-gyp-bin\\
..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild
MSBUILD : error MSB3428: Could not load the Visual C++ component "VCBuild.exe".
To fix this, 1) install the .NET Framework 2.0 SDK, 2) install Microsoft Visua
l Studio 2005 or 3) add the location of the component to the system path if it
is installed elsewhere. [C:\Users\AppData\Roaming\npm\node_modules\generator-mobileangularui\node_modules\slug\n
ode_modules\unicode\node_modules\bufferstream\node_modules\buffertools\build\bi
nding.sln]
gyp ERR! build error
gyp ERR! stack Error: `C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\msbuild.exe
` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\
npm\node_modules\node-gyp\lib\build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:809:
12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "node" "C:\\Program Files\\nodejs\\node_modules\\npm\\node_modu
les\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\AppData\Roaming\npm\node_modules\generato
r-mobileangularui\node_modules\slug\node_modules\unicode\node_modules\bufferstre
am\node_modules\buffertools
gyp ERR! node -v v0.10.29
gyp ERR! node-gyp -v v0.13.1
gyp ERR! not ok
npm WARN optional dep failed, continuing buffertools#2.1.2
|
> unicode#0.6.1 postinstall C:\Users\AppData\Roaming\npm\node_m
odules\generator-mobileangularui\node_modules\slug\node_modules\unicode
> node install.js
try to read file /usr/share/unicode/UnicodeData.txt .
Warning: using slow naiv Buffer.indexOf function!
`npm install buffertools` to speed things up.
/usr/share/unicode/UnicodeData.txt not found.
try to read file /usr/share/unicode-data/UnicodeData.txt .
/usr/share/unicode-data/UnicodeData.txt not found.
try to read file UnicodeData.txt .
UnicodeData.txt not found.
try to download .
GET unicode.org:80/Public/UNIDATA/UnicodeData.txt
fetching .
C:\Users\AppData\Roaming\npm\gulp -> C:\Users\
AppData\Roaming\npm\node_modules\gulp\bin\gulp.js
C:\Users\AppData\Roaming\npm\yo -> C:\Users\Ap
pData\Roaming\npm\node_modules\yo\lib\cli.js
> yo#1.4.6 postinstall C:\Users\AppData\Roaming\npm\node_module
s\yo
> yodoctor
/
Yeoman Doctor
Running sanity checks on your system
V Global configuration file is valid
V NODE_PATH matches the npm root
V No .bowerrc file in home directory
V No .yo-rc.json file in home directory
Everything looks all right!
C:\Users\AppData\Roaming\npm\bower -> C:\Users
\AppData\Roaming\npm\node_modules\bower\bin\bower
gulp#3.8.11 C:\Users\AppData\Roaming\npm\node_modules\gulp
├── interpret#0.3.10
├── pretty-hrtime#0.2.2
├── deprecated#0.0.1
├── archy#1.0.0
├── tildify#1.0.0 (user-home#1.1.1)
├── minimist#1.1.1
├── v8flags#2.0.5 (user-home#1.1.1)
├── semver#4.3.4
├── chalk#0.5.1 (ansi-styles#1.1.0, supports-color#0.2.0, escape-string-regexp#1
.0.3, has-ansi#0.1.0, strip-ansi#0.3.0)
├── orchestrator#0.3.7 (stream-consume#0.1.0, sequencify#0.0.7, end-of-stream#0.
1.5)
├── liftoff#2.0.3 (extend#2.0.1, flagged-respawn#0.3.1, resolve#1.1.6, findup-sy
nc#0.2.1)
├── vinyl-fs#0.3.13 (graceful-fs#3.0.6, strip-bom#1.0.0, vinyl#0.4.6, defaults#1
.0.2, mkdirp#0.5.0, glob-stream#3.1.18, glob-watcher#0.0.6, through2#0.6.5)
└── gulp-util#3.0.4 (array-uniq#1.0.2, array-differ#1.0.0, beeper#1.0.0, lodash.
_reevaluate#3.0.0, object-assign#2.0.0, lodash._reescape#3.0.0, lodash._reinterp
olate#3.0.0, replace-ext#0.0.1, vinyl#0.4.6, chalk#1.0.0, dateformat#1.0.11, lod
ash.template#3.5.1, through2#0.6.5, multipipe#0.1.2)
generator-mobileangularui#1.2.1 C:\Users\AppData\Roaming\npm\no
de_modules\generator-mobileangularui
├── chalk#0.4.0 (ansi-styles#1.0.0, has-color#0.1.7, strip-ansi#0.1.1)
├── yosay#0.1.0 (pad-component#0.0.1, word-wrap#0.1.3, minimist#0.0.9)
├── slug#0.5.0 (unicode#0.6.1)
└── yeoman-generator#0.16.0 (dargs#0.1.0, diff#1.0.8, debug#0.7.4, isbinaryfile#
2.0.4, class-extend#0.1.1, rimraf#2.2.8, async#0.2.10, findup-sync#0.1.3, mime#1
.2.11, text-table#0.2.0, mkdirp#0.3.5, iconv-lite#0.2.11, shelljs#0.2.6, lodash#
2.4.2, underscore.string#2.3.3, glob#3.2.11, file-utils#0.1.5, request#2.30.0, c
heerio#0.13.1, inquirer#0.4.1, download#0.1.19)
yo#1.4.6 C:\Users\AppData\Roaming\npm\node_modules\yo
├── titleize#1.0.0
├── array-uniq#1.0.2
├── figures#1.3.5
├── user-home#1.1.1
├── humanize-string#1.0.1 (decamelize#1.0.0)
├── opn#1.0.2
├── string-length#1.0.0 (strip-ansi#2.0.1)
├── async#0.9.0
├── sort-on#1.2.0 (dot-prop#2.0.0)
├── yeoman-character#1.0.1 (supports-color#1.3.1)
├── cross-spawn#0.2.9 (lru-cache#2.6.2)
├── findup#0.1.5 (commander#2.1.0, colors#0.6.2)
├── root-check#1.0.0 (downgrade-root#1.1.0, sudo-block#1.2.0)
├── yosay#1.0.3 (ansi-styles#2.0.1, word-wrap#1.0.3, ansi-regex#1.1.1, strip-ans
i#2.0.1, pad-component#0.0.1, taketalk#1.0.0, minimist#1.1.1)
├── chalk#1.0.0 (escape-string-regexp#1.0.3, ansi-styles#2.0.1, supports-color#1
.3.1, strip-ansi#2.0.1, has-ansi#1.0.3)
├── meow#3.1.0 (object-assign#2.0.0, camelcase-keys#1.0.0, indent-string#1.2.1,
minimist#1.1.1)
├── update-notifier#0.3.2 (is-npm#1.0.0, latest-version#1.0.0, semver-diff#2.0.0
)
├── npm-keyword#1.1.1 (registry-url#3.0.3)
├── package-json#1.1.0 (registry-url#3.0.3)
├── got#2.9.2 (lowercase-keys#1.0.0, is-stream#1.0.1, timed-out#2.0.0, prepend-h
ttp#1.0.1, nested-error-stacks#1.0.0, infinity-agent#2.0.3, statuses#1.2.1, obje
ct-assign#2.0.0, read-all-stream#2.1.2, duplexify#3.3.0)
├── fullname#1.1.0 (npmconf#2.1.1)
├── configstore#0.3.2 (xdg-basedir#1.0.1, object-assign#2.0.0, osenv#0.1.0, grac
eful-fs#3.0.6, uuid#2.0.1, mkdirp#0.5.0, js-yaml#3.3.0)
├── insight#0.5.3 (object-assign#2.0.0, lodash.debounce#3.0.3, tough-cookie#0.12
.1, os-name#1.0.3, request#2.55.0)
├── yeoman-doctor#1.3.2 (object-values#1.0.0, log-symbols#1.0.2, each-async#1.1.
1, twig#0.7.2)
├── yeoman-environment#1.2.5 (untildify#2.0.0, log-symbols#1.0.2, escape-string-
regexp#1.0.3, diff#1.4.0, text-table#0.2.0, debug#2.1.3, grouped-queue#0.3.0, gl
obby#1.2.0, mem-fs#1.1.0)
├── lodash#3.8.0
└── inquirer#0.8.3 (cli-width#1.0.1, ansi-regex#1.1.1, through#2.3.7, readline2#
0.1.1, rx#2.5.2)
bower#1.4.1 C:\Users\AppData\Roaming\npm\node_modules\bower
├── is-root#1.0.0
├── junk#1.0.1
├── stringify-object#1.0.1
├── chmodr#0.1.0
├── which#1.0.9
├── abbrev#1.0.5
├── rimraf#2.3.3
├── user-home#1.1.1
├── lockfile#1.0.0
├── opn#1.0.2
├── bower-logger#0.2.2
├── bower-endpoint-parser#0.2.2
├── graceful-fs#3.0.6
├── archy#1.0.0
├── nopt#3.0.1
├── retry#0.6.1
├── lru-cache#2.6.2
├── semver#2.3.2
├── p-throttler#0.1.1 (q#0.9.7)
├── tmp#0.0.24
├── request-progress#0.3.1 (throttleit#0.0.2)
├── q#1.3.0
├── shell-quote#1.4.3 (array-filter#0.0.1, array-reduce#0.0.0, array-map#0.0.0,
jsonify#0.0.0)
├── chalk#1.0.0 (escape-string-regexp#1.0.3, ansi-styles#2.0.1, supports-color#1
.3.1, strip-ansi#2.0.1, has-ansi#1.0.3)
├── mkdirp#0.5.0 (minimist#0.0.8)
├── promptly#0.2.0 (read#1.0.5)
├── bower-json#0.4.0 (intersect#0.0.3, deep-extend#0.2.11, graceful-fs#2.0.3)
├── insight#0.5.3 (object-assign#2.0.0, lodash.debounce#3.0.3, async#0.9.0, toug
h-cookie#0.12.1, os-name#1.0.3)
├── glob#4.5.3 (once#1.3.2, inflight#1.0.4, inherits#2.0.1, minimatch#2.0.7)
├── fstream#1.0.5 (inherits#2.0.1)
├── fstream-ignore#1.0.2 (inherits#2.0.1, minimatch#2.0.7)
├── cardinal#0.4.4 (ansicolors#0.2.1, redeyed#0.4.4)
├── decompress-zip#0.1.0 (mkpath#0.1.0, touch#0.0.3, binary#0.3.0, readable-stre
am#1.1.13)
├── tar-fs#1.5.0 (pump#1.0.0, tar-stream#1.1.4)
├── github#0.2.4 (mime#1.3.4)
├── request#2.53.0 (caseless#0.9.0, forever-agent#0.5.2, aws-sign2#0.5.0, tunnel
-agent#0.4.0, oauth-sign#0.6.0, json-stringify-safe#5.0.0, isstream#0.1.2, strin
gstream#0.0.4, qs#2.3.3, node-uuid#1.4.3, combined-stream#0.0.7, mime-types#2.0.
11, form-data#0.2.0, http-signature#0.10.1, hawk#2.3.1, tough-cookie#1.1.0, bl#0
.9.4)
├── update-notifier#0.3.2 (is-npm#1.0.0, string-length#1.0.0, semver-diff#2.0.0,
latest-version#1.0.0)
├── bower-registry-client#0.3.0 (rimraf#2.2.8, request-replay#0.2.0, graceful-fs
#2.0.3, lru-cache#2.3.1, mkdirp#0.3.5, async#0.2.10, request#2.51.0)
├── mout#0.11.0
├── handlebars#2.0.0 (optimist#0.3.7, uglify-js#2.3.6)
├── bower-config#0.6.1 (osenv#0.0.3, graceful-fs#2.0.3, optimist#0.6.1, mout#0.9
.1)
├── configstore#0.3.2 (object-assign#2.0.0, xdg-basedir#1.0.1, osenv#0.1.0, uuid
#2.0.1, js-yaml#3.3.0)
└── inquirer#0.8.0 (figures#1.3.5, ansi-regex#1.1.1, mute-stream#0.0.4, through#
2.3.7, readline2#0.1.1, chalk#0.5.1, lodash#2.4.2, rx#2.5.2, cli-color#0.3.3)
C:\Users\Desktop\Sorgente\weather>yo mobileangularui
Error: Cannot find module 'unicode/category/So'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at symbols (C:\Users\AppData\Roaming\npm\node_modules\gener
ator-mobileangularui\node_modules\slug\slug.js:6:16)
at C:\Users\AppData\Roaming\npm\node_modules\generator-mobi
leangularui\node_modules\slug\slug.js:123:5
at Object.<anonymous> (C:\Users\AppData\Roaming\npm\node_mo
dules\generator-mobileangularui\node_modules\slug\slug.js:130:2)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
I installed the .NET Framework 2.0 SDK but I have the same problem...How can fix it???
My versions:
C:\Users\bla>npm -v
1.4.14
C:\Users\bla>node -v
v0.10.29
C:\Users\bla>cordova -v
4.3.0
Try running:
node-gyp rebuild --msvs-version=2012
Also works with:
--msvs-version=2013

The layout.jade is not working, why?

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.

NodeJS: Express 3.0 with connect-flash( as advised in the passport local strategy), still finding exception for req.flash

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('/');

How to write a package.json file so that all dependencies are downloaded with "npm install"

I wrote a simple application using node. It depends on express, mongodb and mongoose (easy).
So, I created a file called package.json and put this in it:
{
"name": "booking-dojo",
"description": "Booking dojo app",
"version": "0.0.1",
"private": true,
"dependencies": {
"express": "3.x",
"mongodb": "*",
"mongoose": "*"
}
}
I then ran npm install, expecting npm to install those modules and their dependencies.
The result was disappointing:
booking-dojo#0.0.1 /home/merc/Synced/Development/Bookings/app/server
├─┬ express#3.0.0rc3
│ ├── commander#0.6.1
│ ├─┬ connect#2.4.3
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ └── qs#0.4.2
│ ├── 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.0.3
│ └── mime#1.2.6
├─┬ mongodb#1.1.4
│ └── bson#0.1.1
└─┬ mongoose#3.0.3
├── hooks#0.2.1
└── ms#0.1.0
I am confused by this, as I know that express needs jade (and much more), and mongoose needs mongodb.
If I go into node_modules/jade and run npm install, the result from the main tree is very different:
booking-dojo#0.0.1 /home/merc/Synced/Development/Bookings/app/server
├─┬ express#3.0.0rc3
│ ├── commander#0.6.1
│ ├─┬ connect#2.4.3
│ │ ├── bytes#0.1.0
│ │ ├── formidable#1.0.11
│ │ ├── pause#0.0.1
│ │ └── qs#0.4.2
│ ├─┬ connect-redis#1.4.1
│ │ └─┬ redis#0.7.2
│ │ └── hiredis#0.1.14
│ ├── cookie#0.0.4
│ ├── crc#0.2.0
│ ├── debug#0.7.0
│ ├── ejs#0.8.2
│ ├── fresh#0.1.0
│ ├── github-flavored-markdown#1.0.1
│ ├─┬ hjs#0.0.4
│ │ └── hogan.js#2.0.0
│ ├─┬ jade#0.27.2
│ │ └── mkdirp#0.3.0
│ ├── methods#0.0.1
│ ├── mkdirp#0.3.3
│ ├─┬ mocha#1.4.0
│ │ ├── diff#1.0.2
│ │ ├── growl#1.5.1
│ │ └─┬ jade#0.26.3
│ │ └── mkdirp#0.3.0
│ ├── range-parser#0.0.4
│ ├─┬ send#0.0.3
│ │ └── mime#1.2.6
│ ├── should#1.1.0
│ ├─┬ stylus#0.29.0
│ │ └── cssom#0.2.5
│ └─┬ supertest#0.0.1
│ └─┬ superagent#0.5.0
│ ├── emitter-component#0.0.1
│ ├── formidable#1.0.9
│ ├── mime#1.2.5
│ └── qs#0.4.2
├─┬ mongodb#1.1.4
│ └── bson#0.1.1
└─┬ mongoose#3.0.3
├── hooks#0.2.1
└── ms#0.1.0
So, express has grown a lot. It looks like npm install is only loading some of the dependencies of the sub-modules.
Can somebody please shed some light on this? Why are some dependencies missing? Am I doing something wrong? (likely)
Thanks!
Merc.
You are confused about at least 2 points.
First, express does not depend on jade, as you can see by reading the node_modules/express/package.json file:
"dependencies": {
"connect": "2.4.2",
"commander": "0.6.1",
"range-parser": "0.0.4",
"mkdirp": "0.3.3",
"cookie": "0.0.4",
"crc": "0.2.0",
"fresh": "0.1.0",
"methods": "0.0.1",
"send": "0.0.3",
"debug": "*"
}
Express does, however, work with jade if it is available, as well as many other template engines. So to fix this list jade as a dependency in your package.json file and you'll be fine.
Second, npm only installs node packages, not third party things like mongodb. You need to install mongodb and any other dependencies that are not npm modules using other means (apt-get, yum, manual install, etc).
So npm DOES install dependencies recursively, but only npm modules.
The answer was provided by Brandon in a comment to another answer:
"Another thing to note is that if a package depends on a module that can be resolved further up in the dependency chain, it will. For example, since you have mongodb in your package.json, Mongoose doesn't need to install its own mongodb. – Brandon Tilley 2 days ago
Thank you Brandon! (And this is the answer...)
use this sample
{
"name": "app",
"version": "0.0.1",
"main":"test.js",
"author":"Test",
"description": "For test ",
"dependencies": {
"express": "latest",
"mongoose": "latest"
}
}

Resources