1

What is the official method for causing the node_modules folder to be created in a subfolder? I am using Bower for client-side files and happily installing them under a "client" folder. It would be great to use NPM for server-side dependencies and follow the same pattern. For example:

MyApplication
    client
        bower_modules
    server
        node_modules
    .bowerrc
    package.json
    server.js

According to the NPM documentation, it is acceptable to install node modules into a folder other than default location. Unfortunately, uses the --prefix option prevents the dependencies section of package.json from being populating... which leads me to believe this is not the proper way of doing this.

Fred Lackey
  • 2,351
  • 21
  • 34

2 Answers2

1

I would just do:

git mv package.json server # (or just mv if you aren't using git)
cd server
npm install
Peter Lyons
  • 142,938
  • 30
  • 279
  • 274
0

node_modules and package.json follows each other, so you would either have to move your package.json or move your node_modules to the root of your project.

You can still have your client and server folders, that is a good idea!

MyApplication
    node_modules
        express
        socket.io
    client
        bower_components/jquery/jquery.js
        client.js
    server
        server.js
    .bowerrc
    package.json
    server.js
Kevin Simper
  • 1,669
  • 19
  • 32