Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
danielbush opened this issue Sep 24, 2014 · 2 comments
Open

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

danielbush opened this issue Sep 24, 2014 · 2 comments

Comments

@danielbush
Copy link

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
Copy link

eush77 commented Feb 23, 2015

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 <script> tag:

<script src="bundle.js"></script>

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

@LaurieSReynolds
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants