Installing project's dependencies globally and running the project without
`node_modules/` — how?
I decided to try learning DerbyJS and this is my first acquaintance with
NodeJS either.
I create a new Node/Derby project with derby new foo. This also creates a
node_modules/ folder which contains a copy of all packages the project
depends on.
The node_modules/ subdir of a blank Derby project is 144 MB large and
contains 12967 files (sic!). As a person familiar with Ruby's RubyGems,
RVM and Bundler, i find this insane. I can't express how wrong it is
(actually i've got some solid argumentation against that craziness but
StackOverflow is not a place for debate).
I thought that npm's -g flag would help me. I could install all packages
globally, i told myself. So i did:
derby new -n foo
cd foo
sudo npm install -g
Now my project weighs 152 KB and contains 24 files. Now that's reasonable.
But i fail to run it. When i do npm start, i get "Cannot find module
'express'":
lolmaus@sandy:~/hello_derby2$ npm start
> hello_derby2@0.0.0 start /home/lolmaus/hello_derby2
> node server.js
Master pid 29884
module.js:340
throw err;
^
Error: Cannot find module 'express'
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>
(/home/lolmaus/hello_derby2/lib/server/index.js:1:77)
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)
at require (module.js:380:17)
So the question is: how do install project's dependencies into a central
local repository and run the project without beating the f#@k out of my
Dropbox account?
No comments:
Post a Comment