8

I'm just starting out with npm. I use visual studio and everything is working great. I've got my packages installed.

How do I go about publishing the website with the node modules? If I publish the site within visual studio 2015 right now, it is missing all the scripts installed via npm.

Do I need to include the npm_modules folder in my project? If so I've tried just to test, and it seems to freeze VS2015 on every attempt. I've failed to find information on how to do this. I'm guessing there is an easy fix that I'm just not aware of.

Thanks!

Dylan
  • 1,068
  • 12
  • 25
  • 1
    If you look at the size of your node_modules and the number of files you will probably find it prohibitively large. You should consider bundling your application with webpack, rollup, or SystemJS builder to include what you need and discard most of what you don't for deployment. – silentsod Oct 20 '16 at 22:03
  • 1
    Probably the biggest pain with deploying node apps in Windows is that the node_modules hierarchy quickly gets too deep to deploy (see http://stackoverflow.com/questions/21731066/too-long-paths-because-of-nested-node-dependencies). Building the JS as @silentsod noted would be beneficial to mitigate that problem too. – mherzig Oct 21 '16 at 00:28
  • 1
    How would I bundle it so I only use what I need, but still keep it so I can update to new versions with npm? Obviously I could just grab the single files and through them in the scripts folder, but what's the point of npm then? – Dylan Oct 21 '16 at 00:55
  • 1
    The bundling tools will take only what you need for a production deploy if you set them up correctly which is outside the scope of the comments but readily available (for instance: https://webpack.github.io/). You are free to update your packages at any time and rebundle them. NPM is, really and truly, just a package management tool for you to use in development to get what you need and it does its job. I would not suggest using it for deploys in Windows because my bundled (and minified) JS for an app is 1MB and my node_modules folder is 200MB. – silentsod Oct 21 '16 at 15:14

1 Answers1

0

A brute force solution is to set the following project setting: tab 'Package/Publish Web Set 'Items to deploy ....' to 'All files in this project folder

See also this answer: How to "Add Existing Item" an entire directory structure in Visual Studio?

Community
  • 1
  • 1
klaasjan69
  • 181
  • 2
  • 7