node.jsgulpbrowserifynode-modulesbrowserify-shim

browserify-shim error when node_modules folder is a symlink


On the production server node_modules folder is a symbolic link for continuous deployment purposes. When I run gulp command, I got many errors like this: Error: Unable to find a browserify-shim config section in the package.json for /home/web/www/persist/node_modules/jquery-ui/jquery-ui.js while parsing file: /home/web/www/persist/node_modules/jquery-ui/jquery-ui.js] filename: '/home/web/www/persist/node_modules/jquery-ui/jquery-ui.js' . . . If I move node_modules in project folder, build process is successfull. How to solve this problem?


Solution

  • Answer from thlorenz (author of browserify-shim)

    Linking breaks browserify and shim since your projects dependencies are outside of your project tree. So when looking upwards these tools can't find the package.json of your package anymore.

    So don't link your node_modules folders .. it's a bad idea anyways since you're then linked to a global in your system, i.e. it's better to have all your deps be local to your project. Not sure what your deployment purposes are, but to me it seems like whoever made that decision didn't fully understand how node/npm is supposed to work.