semmypurewal/LearningWebAppDev

Questions about install nTwitter

Closed this issue · 11 comments

On the Errata for page 197 you mention the ls node_modules is wrong. However, node_modules was installed in the Twitter directory when I ran npm install ntwitter from it but I don't see express.

Is this discrepancy important? Should I make sure that node_modules is in the the app directory? What about express? Do I need to make sure it is in the Twitter directory?

Thanks

Hi!

Thanks for the note, and sorry for the confusion. The node_modules directory should be in the closest directory with a package.json file. So if you have a package.json file in the Twitter directory, it will be installed there.

Node's module resolution will first look for a node_modules directory in the current directory, and if there's not one, it will look for it in the directory above, and so on until it finds it or it runs out of directories.

If express is not there, you might try npm install express@3 in the same directory that you installed ntwitter and see if you see it then.

If you're still having problems, you can reply here with more info, or you can feel free to zip up and e-mail me your code or a link to a github repository and I can troubleshoot it for you. If you're not sure how to do those things, just let me know and we can work something else out.

Hope this helps!

-Semmy

Hey Semmy,

Thanks for responding.

The thing that happened is that:

  1. I created the Twitter directory and then went into it.
  2. I ran npm install ntwitter while in the Twitter directory
  3. A node_modules directory was installed in the Twitter directory, even though there is no package.json file in there.
  4. Inside the node_modules directory is a directory for ntwitter but not one for express.

Should I install express in the Twitter directory or in Twitter/node_modules/?
Here is a link to the Github repo. It is named Chapter 6-1 because when I first pushed it to Github it was greyed for some reason, so I just deleted and re inserted every file or folder piece by piece, pushing them to Github and hoping they don't get greyed out.

Yeah, it sounds like you'll need to npm install express@3 in the Twitter directory. From a quick glance, I don't quite understand why it would install in that directory, but let's give it a try anyway.

Hi Semmy, i'm presently having the same issues with egdenard. While I tried installing express with 'npm install express@3' in the Twitter directory, this is the npm-debug file I posted. When i added the --no bin-links of a thing I don't think it added the whole file because I cross-checked it with the the files on your repo. I've even tried copying all your codes word for word... I just wasn't successful renaming a folder as .bin. I just want this thing to work. I've been on it for days now. Kindly help!

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli 'install',
1 verbose cli 'express@3' ]
2 info using npm@1.4.14
3 info using node@v0.10.29
4 verbose node symlink /usr/local/bin/node
5 verbose cache add [ 'express@3', null ]
6 verbose cache add name=undefined spec="express@3" args=["express@3",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url slashes: null,
7 verbose parsed url auth: null,
7 verbose parsed url host: null,
7 verbose parsed url port: null,
7 verbose parsed url hostname: null,
7 verbose parsed url hash: null,
7 verbose parsed url search: null,
7 verbose parsed url query: null,
7 verbose parsed url pathname: 'express@3',
7 verbose parsed url path: 'express@3',
7 verbose parsed url href: 'express@3' }
8 verbose cache add name="express" spec="3" args=["express","3"]
9 verbose parsed url { protocol: null,
9 verbose parsed url slashes: null,
9 verbose parsed url auth: null,
9 verbose parsed url host: null,
9 verbose parsed url port: null,
9 verbose parsed url hostname: null,
9 verbose parsed url hash: null,
9 verbose parsed url search: null,
9 verbose parsed url query: null,
9 verbose parsed url pathname: '3',
9 verbose parsed url path: '3',
9 verbose parsed url href: '3' }
10 verbose addNamed [ 'express', '3' ]
11 verbose addNamed [ null, '>=3.0.0-0 <4.0.0-0' ]
12 silly lockFile a2896986-express-3 express@3
13 verbose lock express@3 /home/vagrant/.npm/a2896986-express-3.lock
14 silly addNameRange { name: 'express', range: '>=3.0.0-0 <4.0.0-0', hasData: false }
15 verbose url raw express
16 verbose url resolving [ 'https://registry.npmjs.org/', './express' ]
17 verbose url resolved https://registry.npmjs.org/express
18 info trying registry request attempt 1 at 08:05:49
19 verbose etag "3XJ9HQR8B57CLQRJ0HTJ1GH5I"
20 http GET https://registry.npmjs.org/express
21 http 304 https://registry.npmjs.org/express
22 silly registry.get cb [ 304,
22 silly registry.get { date: 'Sun, 19 Oct 2014 00:00:16 GMT',
22 silly registry.get server: 'Apache',
22 silly registry.get via: '1.1 varnish',
22 silly registry.get 'last-modified': 'Sun, 19 Oct 2014 00:00:16 GMT',
22 silly registry.get 'cache-control': 'max-age=60',
22 silly registry.get etag: '"3XJ9HQR8B57CLQRJ0HTJ1GH5I"',
22 silly registry.get age: '10',
22 silly registry.get 'x-served-by': 'cache-fra1233-FRA',
22 silly registry.get 'x-cache': 'HIT',
22 silly registry.get 'x-cache-hits': '1',
22 silly registry.get 'x-timer': 'S1413676816.387104,VS0,VE2',
22 silly registry.get vary: 'Accept',
22 silly registry.get 'content-length': '0',
22 silly registry.get 'keep-alive': 'timeout=10, max=50',
22 silly registry.get connection: 'Keep-Alive' } ]
23 verbose etag express from cache
24 silly addNameRange number 2 { name: 'express', range: '>=3.0.0-0 <4.0.0-0', hasData: true }
25 silly addNameRange versions [ 'express',
25 silly addNameRange [ '0.14.0',
25 silly addNameRange '0.14.1',
25 silly addNameRange '1.0.0',
25 silly addNameRange '1.0.1',
25 silly addNameRange '1.0.2',
25 silly addNameRange '1.0.3',
25 silly addNameRange '1.0.4',
25 silly addNameRange '1.0.5',
25 silly addNameRange '1.0.6',
25 silly addNameRange '1.0.7',
25 silly addNameRange '1.0.8',
25 silly addNameRange '2.0.0',
25 silly addNameRange '2.1.0',
25 silly addNameRange '2.1.1',
25 silly addNameRange '2.2.0',
25 silly addNameRange '2.2.1',
25 silly addNameRange '2.2.2',
25 silly addNameRange '2.3.0',
25 silly addNameRange '2.3.1',
25 silly addNameRange '2.3.2',
25 silly addNameRange '2.3.3',
25 silly addNameRange '2.3.4',
25 silly addNameRange '2.3.5',
25 silly addNameRange '2.3.6',
25 silly addNameRange '2.3.7',
25 silly addNameRange '2.3.8',
25 silly addNameRange '2.3.9',
25 silly addNameRange '2.3.10',
25 silly addNameRange '2.3.11',
25 silly addNameRange '2.3.12',
25 silly addNameRange '2.4.0',
25 silly addNameRange '2.4.1',
25 silly addNameRange '2.4.2',
25 silly addNameRange '2.4.3',
25 silly addNameRange '2.4.4',
25 silly addNameRange '2.4.5',
25 silly addNameRange '2.4.6',
25 silly addNameRange '2.4.7',
25 silly addNameRange '2.5.0',
25 silly addNameRange '2.5.1',
25 silly addNameRange '2.5.2',
25 silly addNameRange '2.5.3',
25 silly addNameRange '2.5.4',
25 silly addNameRange '2.5.5',
25 silly addNameRange '2.5.6',
25 silly addNameRange '2.5.7',
25 silly addNameRange '2.5.8',
25 silly addNameRange '2.5.9',
25 silly addNameRange '2.5.10',
25 silly addNameRange '2.5.11',
25 silly addNameRange '3.0.0',
25 silly addNameRange '3.0.1',
25 silly addNameRange '3.0.2',
25 silly addNameRange '3.0.3',
25 silly addNameRange '3.0.4',
25 silly addNameRange '3.0.5',
25 silly addNameRange '3.0.6',
25 silly addNameRange '3.1.0',
25 silly addNameRange '3.1.1',
25 silly addNameRange '3.1.2',
25 silly addNameRange '3.2.0',
25 silly addNameRange '3.2.1',
25 silly addNameRange '3.2.2',
25 silly addNameRange '3.2.3',
25 silly addNameRange '3.2.4',
25 silly addNameRange '3.2.5',
25 silly addNameRange '3.2.6',
25 silly addNameRange '3.3.0',
25 silly addNameRange '3.3.1',
25 silly addNameRange '3.3.2',
25 silly addNameRange '3.3.3',
25 silly addNameRange '3.3.4',
25 silly addNameRange '3.3.5',
25 silly addNameRange '3.3.6',
25 silly addNameRange '1.0.0-beta',
25 silly addNameRange '1.0.0-beta2',
25 silly addNameRange '1.0.0-rc',
25 silly addNameRange '1.0.0-rc2',
25 silly addNameRange '1.0.0-rc3',
25 silly addNameRange '1.0.0-rc4',
25 silly addNameRange '2.0.0-beta',
25 silly addNameRange '2.0.0-beta2',
25 silly addNameRange '2.0.0-beta3',
25 silly addNameRange '2.0.0-rc',
25 silly addNameRange '2.0.0-rc2',
25 silly addNameRange '2.0.0-rc3',
25 silly addNameRange '3.0.0-alpha1',
25 silly addNameRange '3.0.0-alpha2',
25 silly addNameRange '3.0.0-alpha3',
25 silly addNameRange '3.0.0-alpha4',
25 silly addNameRange '3.0.0-alpha5',
25 silly addNameRange '3.0.0-beta1',
25 silly addNameRange '3.0.0-beta2',
25 silly addNameRange '3.0.0-beta3',
25 silly addNameRange '3.0.0-beta4',
25 silly addNameRange '3.0.0-beta6',
25 silly addNameRange '3.0.0-beta7',
25 silly addNameRange '3.0.0-rc1',
25 silly addNameRange '3.0.0-rc2',
25 silly addNameRange '3.0.0-rc3',
25 silly addNameRange '3.0.0-rc4',
25 silly addNameRange '3.0.0-rc5',
25 silly addNameRange '3.3.7',
25 silly addNameRange '3.3.8',
25 silly addNameRange '3.4.0',
25 silly addNameRange '3.4.1',
25 silly addNameRange '3.4.2',
25 silly addNameRange '3.4.3',
25 silly addNameRange '3.4.4',
25 silly addNameRange '3.4.5',
25 silly addNameRange '3.4.6',
25 silly addNameRange '3.4.7',
25 silly addNameRange '3.4.8',
25 silly addNameRange '4.0.0-rc1',
25 silly addNameRange '4.0.0-rc2',
25 silly addNameRange '3.5.0',
25 silly addNameRange '4.0.0-rc3',
25 silly addNameRange '4.0.0-rc4',
25 silly addNameRange '3.5.1',
25 silly addNameRange '4.0.0',
25 silly addNameRange '3.5.2',
25 silly addNameRange '4.1.0',
25 silly addNameRange '4.1.1',
25 silly addNameRange '3.5.3',
25 silly addNameRange '4.1.2',
25 silly addNameRange '3.6.0',
25 silly addNameRange '4.2.0',
25 silly addNameRange '3.7.0',
25 silly addNameRange '3.8.0',
25 silly addNameRange '4.3.0',
25 silly addNameRange '4.3.1',
25 silly addNameRange '3.8.1',
25 silly addNameRange '4.3.2',
25 silly addNameRange '3.9.0',
25 silly addNameRange '4.4.0',
25 silly addNameRange '4.4.1',
25 silly addNameRange '3.10.0',
25 silly addNameRange '3.10.1',
25 silly addNameRange '3.10.2',
25 silly addNameRange '3.10.3',
25 silly addNameRange '3.10.4',
25 silly addNameRange '4.4.2',
25 silly addNameRange '3.10.5',
25 silly addNameRange '4.4.3',
25 silly addNameRange '3.11.0',
[I had to cut the remaining due to space constraints]

Hi @samseen -- I don't think this is the same issue that @edgenard was having, but I could be wrong. I think @edgenard's problem is that express was being installed in a weird place, but it seems like everything is working otherwise (at least I haven't heard anymore about this issue).

In your case, it sounds like there's a discrepancy between what is being installed and what is in my repository.

It sounds like npm is giving you an error when you run the following command:

$ npm install express@3 --no-bin-links

Is that correct? If so, what's the exact error you're seeing when you run this command? If you're not seeing an error there, what is the error you're seeing when trying to run the your program that uses express?

Just to confirm -- you're running this on windows? If so, when you do --no-bin-links, it shouldn't create the .bin directory, so that behavior is correct.

Alright Semmy, I'm sure npm doesn't give me an error when I run ' $ npm install express@3 --no-bin-links '. It ran fine and I saw a shiny new express folder in the node_modules directory. This is the error I see when I run 'node tweet_counter' from the Twitter directory:
events.js:74
throw TypeError('Uncaught, unspecified "error" event.');
^
TypeError: Uncaught, unspecified "error" event.
at TypeError ()
at EventEmitter.emit (events.js:74:15)
at ClientRequest. (/home/vagrant/app/Twitter/node_modules/ntwitter/lib/twitter.js:251:14)
at ClientRequest.emit (events.js:95:17)
at HTTPParser.parserOnIncomingClient as onIncoming
at HTTPParser.parserOnHeadersComplete as onHeadersComplete
at CleartextStream.socketOnData as ondata
at CleartextStream.read as _read
at CleartextStream.Readable.read (_stream_readable.js:323:10)
at EncryptedStream.write as _write
The only files I have in my Twitter directory are: node_modules, credentials.json and tweet_counter. Am I on track? I do appreciate your quick response.

I'm about 90% sure that this issue is due to your credentials.json file. Did you put it in the correct format? Don't post it here, but can you e-mail it to me? I can make sure the format is correct.

Also, you'll need to make sure that your credentials are exactly as they are specified by Twitter. This link may help.

Of course, I can send you my credentials. What's your email address?

It's in the preface of the book! :)

(Don't want to post it here, because of spam).

All right, i've sent it.

@samseen and I have worked through his issue over e-mail, and I haven't heard from @edgenard again about this.

@edgenard, please feel free to reopen this issue or open a new one if you're still hitting these problems!