npm / npm

This repository is moving to: https://github.com/npm/cli
http://npm.community
17.54k stars 3.02k forks source link

Error: Cannot find module 'cson' #1106

Closed balupton closed 13 years ago

balupton commented 13 years ago

Hey Isaac,

So I've published my module buildr which uses another one of my modules called cson, but when I try to run buildr I get Error: Cannot find module 'cson'. Here is the full log. This really has me scratching my head... :/

$ node -v v0.4.9 $ npm -v 1.0.15 $ npm -g install buildr /usr/local/bin/buildr -> /usr/local/lib/node_modules/buildr/bin/buildr.coffee buildr@0.4.4 /usr/local/lib/node_modules/buildr ├── bal-util@0.4.0 ├── cson@0.1.1 ├── coffee-script@1.1.1 └── less@1.1.2 $ buildr Error: Cannot find module 'cson' at Function._resolveFilename (module.js:317:11) at Function._load (module.js:262:25) at require (module.js:346:19) at Object. (/usr/local/lib/node_modules/buildr/bin/buildr.coffee:3:10) at Object. (/usr/local/lib/node_modules/buildr/bin/buildr.coffee:18:4) at Module._compile (module.js:402:26) at Object.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script.js:62:19) at /usr/local/lib/node_modules/coffee-script/lib/command.js:120:29 at /usr/local/lib/node_modules/coffee-script/lib/command.js:90:26 at [object Object]. (fs.js:107:5)

isaacs commented 13 years ago

This is a coffee-script bug. Looks like it doesn't use node's module lookup when you use the "coffee" command.

@jashkenas?

npm explore -g buildr
node
> require("coffee-script"); require("cson")
{ parseFile: [Function], parse: [Function], stringify: [Function] }

$ coffee
coffee> require("cson")
Error: Cannot find module 'cson'
    at Function._resolveFilename (module.js:317:11)
    at Function._load (module.js:262:25)
    at require (module.js:346:19)
    at repl:2:5
    at Object.eval (/usr/local/lib/node_modules/coffee-script/lib/coffee-script.js:89:15)
    at Interface.<anonymous> (/usr/local/lib/node_modules/coffee-script/lib/repl.js:39:28)
    at Interface.emit (events.js:64:17)
    at Interface._onLine (readline.js:153:10)
    at Interface._line (readline.js:408:8)
    at Interface._ttyWrite (readline.js:585:14)
balupton commented 13 years ago

Thanks @isaacs - I reposted on the coffee-script issues here https://github.com/jashkenas/coffee-script/issues/1485

ghost commented 7 years ago

This is a really weird error I keep getting. Been digging around google trying to find a solution, but can't find one. I did a global install for cson and when I run node and attempt to import the cson module with require(), I get an error.

$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 16.04.2 LTS
Release:    16.04
Codename: xenial

I did a fresh install of the latest stable versions for node and npm and updated npm afterwards. I then ran the following commands.

$ node --version
v6.10.3
$ npm --version
4.5.0
$ sudo npm install --save -g cson
/usr/bin/cson2json -> /usr/lib/node_modules/cson/bin/cson2json
/usr/bin/json2cson -> /usr/lib/node_modules/cson/bin/json2cson
/usr/lib
└─┬ cson@4.1.0 
  ├── coffee-script@1.12.5 
  ├─┬ cson-parser@1.3.5 
  │ └── coffee-script@1.12.5  deduped
  ├─┬ extract-opts@3.3.1 
  │ ├─┬ eachr@3.2.0 
  │ │ ├── editions@1.3.3  deduped
  │ │ └── typechecker@4.4.1  deduped
  │ ├── editions@1.3.3 
  │ └─┬ typechecker@4.4.1 
  │   └── editions@1.3.3  deduped
  ├─┬ requirefresh@2.1.0 
  │ └── editions@1.3.3  deduped
  └─┬ safefs@4.1.0 
    ├── editions@1.3.3  deduped
    └── graceful-fs@4.1.11 

When I went to test out if I could import the cson module, I got this output.

$ node
> var CSON = require('cson');
Error: Cannot find module 'cson'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at repl:1:12
    at sigintHandlersWrap (vm.js:22:35)
    at sigintHandlersWrap (vm.js:73:12)
    at ContextifyScript.Script.runInThisContext (vm.js:21:12)
    at REPLServer.defaultEval (repl.js:346:29)
    at bound (domain.js:280:14)
> 

Any help with this would be greatly appreciated. Keep in mind, I am still new to using node. Not sure if this is a config issue on my end or if it has to do with cson. I posted there too.