Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of "npm install" on the server side is considered a bad practice #14

Open
boutell opened this issue Dec 12, 2013 · 5 comments
Open

Comments

@boutell
Copy link
Contributor

boutell commented Dec 12, 2013

See:

https://github.com/isaacs/npm/issues/4304

I complained that npm publish does not have read-after-write consistency so I can't script doing a deploy after a publish of a public npm module and get reliable results.

The response was that I shouldn't be doing that anyway. Both for that reason and to avoid slamming npm's servers.

The proper practice would be to copy node_modules after all, as we did in the dawn days of stagecoach - then do a recursive "npm rebuild" on all the modules, to address binary incompatibility issues that caused us to use "npm install" remotely in the first place.

@coreytegeler
Copy link

I know this is old, but is this still the case?

I get errors from npm install and it might be in my favor to try and copy the node_modules folder or manually install them so I can work through errors rather than having the whole deployment stop and deleted

@boutell
Copy link
Contributor Author

boutell commented Apr 20, 2016

Well, the difficulties are mostly human and a little bit technical:

  1. We maintain a lot of modules which are npm linked in our projects. If
    deploying the app deploys the modules in their current hacked-up state, we
    may never commit and publish them responsibly (:

Forcing the use of npm install on the server side is one way to ensure that
code in our own source projects gets committed, pushed and published
properly if we want to use it in production.

  1. Deploying "npm link"ed modules by copying them is pretty challenging,
    even if it were a good idea. We'd have to configure rsync to copy through
    the symbolic links. Probably a better idea to detect whether npm link is in
    use and force the use of npm install if it is... but now sc-deploy has to
    check for this issue first... yuck.
  2. You can't, in fact, just copy over your node_modules folder in all
    cases. npm modules can and often do have C++ compiled components which are
    platform specific. Sometimes it's just a performance thing, other times
    you're actually out of luck without them.

However, you can in principle copy over your node_modules folder and then
do "npm rebuild" to recompile anything platform-specific.

So right now our recommendation is to make sure you have enough RAM for npm
to do its job. (Yes, it's a real pig.)

On Wed, Apr 20, 2016 at 12:34 PM, Corey Tegeler [email protected]
wrote:

I know this is old, but is this still the case?

I get errors from npm install and it might be in my favor to try and copy
the node_modules folder or manually install them so I can work through
errors rather than having the whole deployment stop and deleted


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#14 (comment)

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

@boutell
Copy link
Contributor Author

boutell commented Apr 20, 2016

However... nobody's stopping you from trying this in your project:

  1. Change rsync_exclude.txt so that node_modules gets copied.
  2. Edit deployment/dependencies to do "npm rebuild" rather than "npm
    install".

If you don't have any "npm link"ed modules, it ought to work, and I'd be
curious to hear about your experiences with it.

(Modifying these files is something you're intended to do. The deployment/
scripts are meant to get changed as needed to support individual projects.)

On Wed, Apr 20, 2016 at 12:42 PM, Tom Boutell [email protected] wrote:

Well, the difficulties are mostly human and a little bit technical:

  1. We maintain a lot of modules which are npm linked in our projects. If
    deploying the app deploys the modules in their current hacked-up state, we
    may never commit and publish them responsibly (:

Forcing the use of npm install on the server side is one way to ensure
that code in our own source projects gets committed, pushed and published
properly if we want to use it in production.

  1. Deploying "npm link"ed modules by copying them is pretty challenging,
    even if it were a good idea. We'd have to configure rsync to copy through
    the symbolic links. Probably a better idea to detect whether npm link is in
    use and force the use of npm install if it is... but now sc-deploy has to
    check for this issue first... yuck.
  2. You can't, in fact, just copy over your node_modules folder in all
    cases. npm modules can and often do have C++ compiled components which are
    platform specific. Sometimes it's just a performance thing, other times
    you're actually out of luck without them.

However, you can in principle copy over your node_modules folder and then
do "npm rebuild" to recompile anything platform-specific.

So right now our recommendation is to make sure you have enough RAM for
npm to do its job. (Yes, it's a real pig.)

On Wed, Apr 20, 2016 at 12:34 PM, Corey Tegeler [email protected]
wrote:

I know this is old, but is this still the case?

I get errors from npm install and it might be in my favor to try and
copy the node_modules folder or manually install them so I can work through
errors rather than having the whole deployment stop and deleted


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#14 (comment)

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

@coreytegeler
Copy link

Wonderful, this let me get passed the initial deployment very painfully.

I had done each step manually to make sure it worked before editing the scripts, but it's great to be able to customize those!

Thanks for the guide

@boutell
Copy link
Contributor Author

boutell commented Apr 20, 2016

Glad to hear this alternative does work! We will keep considering the best
way to handle it in our own work.

On Wed, Apr 20, 2016 at 1:08 PM, Corey Tegeler [email protected]
wrote:

Wonderful, this let me get passed the initial deployment very painfully.

I had done each step manually to make sure it worked before editing the
scripts, but it's great to be able to customize those!

Thanks for the guide


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#14 (comment)

*THOMAS BOUTELL, *DEV & OPS
P'UNK AVENUE | (215) 755-1330 | punkave.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants