workshopper / browserify-adventure

learn browserify with this educational adventure
Other
143 stars 21 forks source link

"Using npm packages" / problem 2 - issue with "prompt" #12

Open danielbush opened 10 years ago

danielbush commented 10 years ago

Hi, My node doesn't have "prompt". If I use the "prompt" npm module, the solution looks different to the one I can see in https://github.com/substack/browserify-adventure/blob/master/solutions/using_npm_packages/main.js currently.

So I tried using npm "prompt" but I get an error when piping to browserify-adventure run. (I get: "undefined:869 \n var files = fs.readdirSync(dir); ...")

eush77 commented 9 years ago

Node does not have prompt, browsers do. If you would like to run the solution yourself, you should follow the instructions from the first exercise:

We piped the output of browserify into the verify command directly, but ordinarily to use browserify in your page you would do:

browserify beep_boop.js > bundle.js

and then in your html, you just add a single

Open html page in the browser and turn on the console to see the output.

LaurieSReynolds commented 8 years ago

I am getting the same problem - how should verify be run?

Here's my code which runs fine stand alone

var uniq = require("uniq") var prompt = require('prompt')

prompt.start() prompt.get(['message'], function(err, result) { console.log(uniq(result.message.split(','))) })

Here's my output

prompt: message: one,two,three,two,three,four,three,four,five,six [ 'five', 'four', 'one', 'six', 'three', 'two' ]

When I follow the directions to verify or run

browserify usingNPM.js | browserify-adventure run
undefined:12081
  var files = fs.readdirSync(dir);
                 ^

TypeError: fs.readdirSync is not a function
    at Function.pkginfo.find (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:12081:18)
    at Function.pkginfo.read (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:12105:17)
    at module.exports (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:12055:21)
    at Object.eval (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:12118:1)
    at Object.prompt.70.fs (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:12123:4)
    at s (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:3:254)
    at eval (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:3:305)
    at Object.prompt.48../winston/common (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:8504:1)
    at s (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:3:254)
    at eval (eval at <anonymous> (/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:76:13), <anonymous>:3:305)

browserify usingNPM.js | browserify-adventure verify

TAP version 13

(anonymous)

not ok 1 2 files


operator: equal
expected: 2
actual:   210
at: ConcatStream.<anonymous> (/usr/local/lib/node_modules/browserify-adventure/node_modules/concat-stream/index.js:36:43)

... not ok 2 No entry file detected


operator: fail
at: ConcatStream.<anonymous> (/usr/local/lib/node_modules/browserify-adventure/node_modules/concat-stream/index.js:36:43)

...

/usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:30 Object.keys(main.deps), ['uniq'], ^

TypeError: Cannot read property 'deps' of undefined at /usr/local/lib/node_modules/browserify-adventure/problems/using_npm_packages/index.js:30:29 at ConcatStream. (/usr/local/lib/node_modules/browserify-adventure/node_modules/concat-stream/index.js:36:43) at emitNone (events.js:72:20) at ConcatStream.emit (events.js:166:7) at finishMaybe (/usr/local/lib/node_modules/browserify-adventure/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:475:14) at endWritable (/usr/local/lib/node_modules/browserify-adventure/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:485:3) at ConcatStream.Writable.end (/usr/local/lib/node_modules/browserify-adventure/node_modules/concat-stream/node_modules/readable-stream/lib/_stream_writable.js:455:41) at Socket.onend (_stream_readable.js:498:10) at Socket.g (events.js:260:16) at emitNone (events.js:72:20)

using 
Node: 4.4.2
Browserify: ?? - not sure how to get version info for this.