npm Cannot find module tobi-cookie; npm unable to

2019-09-05 09:42发布

问题:

I'm trying to install express, but I can't get passed this "tobi-cookie" error.

I installed Connect via npm a few days ago, and it said it was missing tobi-cookie.

I then installed tobi-cookie.

Today I was trying to install Express, and got this back:

[root@dsusim:/home/GUIServer]$ npm info express version
npm http GET http://registry.npmjs.org/express
npm ERR! TypeError: Cannot read property 'url' of undefined
npm ERR!     at new Cookie (/usr/lib/node_modules/tobi-cookie/index.js:46:20)
npm ERR!     at addCookie (/usr/lib/node_modules/request/main.js:586:26)
npm ERR!     at Array.forEach (native)
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/node_modules/request/main.js:590:89)
npm ERR!     at ClientRequest.g (events.js:175:14)
npm ERR!     at ClientRequest.EventEmitter.emit (events.js:95:17)
npm ERR!     at HTTPParser.parserOnIncomingClient [as onIncoming] (http.js:1628:21)
npm ERR!     at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:119:23)
npm ERR!     at Socket.socketOnData [as ondata] (http.js:1523:20)
npm ERR!     at TCP.onread (net.js:510:27)
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.8.7-201.fc18.x86_64
npm ERR! command "node" "/bin/npm" "info" "express" "version"
npm ERR! cwd /home/GUIServer
npm ERR! node -v v0.10.4
npm ERR! npm -v 1.2.14
npm ERR! type non_object_property_load
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/GUIServer/npm-debug.log
npm ERR! not ok code 0

I then proceeded to 'npm uninstall' then 'npm rm' tobie-cookie.

Now I'm in big trouble... can't install anything:

[root@localhost:/usr/lib]$ npm info express version

module.js:340
    throw err;
          ^
Error: Cannot find module 'tobi-cookie'
    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 Object.<anonymous> (/usr/lib/node_modules/request/main.js:26:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

.

[root@localhost:/usr/lib]$ npm install tobi-cookie

module.js:340
    throw err;
          ^
Error: Cannot find module 'tobi-cookie'
    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 Object.<anonymous> (/usr/lib/node_modules/request/main.js:26:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

.

[root@localhost:/usr/lib]$ npm install tobi-cookie -g

module.js:340
    throw err;
          ^
Error: Cannot find module 'tobi-cookie'
    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 Object.<anonymous> (/usr/lib/node_modules/request/main.js:26:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

.

[root@localhost:/usr/lib]$ ls /usr/lib/node_modules/
abbrev           config-chain      fresh              lru-cache               npmlog               read-installed     socket.io
ansi             connect           fstream            mime                    npm-registry-client  read-package-json  tar
archy            connect-master    fstream-ignore     minimatch               once                 request            uid-number
async            cookie            fstream-npm        mkdirp                  opener               retry              which
block-stream     cookie-signature  glob               mute-stream             osenv                rimraf
buffer-crc32     couch-login       graceful-fs        node-browserify-master  pause                semver
bytes            debug             inherits           node-gyp                promzard             send
chmodr           delayed-stream    ini                nopt                    proto-list           session.socket.io
chownr           form-data         init-package-json  npm                     qs                   sigmund
combined-stream  formidable        lockfile           npmconf                 read                 slide

.

[root@localhost:/home/GUIServer]$ npm update

module.js:340
    throw err;
          ^
Error: Cannot find module 'tobi-cookie'
    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 Object.<anonymous> (/usr/lib/node_modules/request/main.js:26:14)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

.

[root@localhost:/home/GUIServer]$ locate tobi-cookie
/usr/lib/node_modules/tobi-cookie
/usr/lib/node_modules/request/node_modules/tobi-cookie
/usr/share/doc/nodejs-tobi-cookie-0.3.2
/usr/share/doc/nodejs-tobi-cookie-0.3.2/History.md
/usr/share/doc/nodejs-tobi-cookie-0.3.2/Readme.md

回答1:

I used this command npm link express. worked for me..I reinstall the express and I went to directory where my project is located and I performed the npm link epress and worked find. http://blog.i-evaluation.com/2012/09/17/error-cannot-find-module-express/



回答2:

Nevermind, solved it with:

git clone git://github.com/isaacs/npm.git
cd npm/scripts
chmod +x install.sh
sudo ./install.sh

from NPM, cannot find 'graceful-fs', no matter what I do

and from NPM can't install appjs. Error: Cannot find module 'graceful-fs'

then did

/bin/npm install express -g
/bin/npm install express