node_modules 文件夹是符号链接时出现 browserify-shim 错误
browserify-shim error when node_modules folder is a symlink
在生产服务器上 node_modules 文件夹是一个用于持续部署目的的符号 link。
当我 运行 gulp 命令时,我得到了很多这样的错误:
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'
. . .
如果我在项目文件夹中移动 node_modules,则构建过程成功。如何解决这个问题?
来自 thlorenz(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.
在生产服务器上 node_modules 文件夹是一个用于持续部署目的的符号 link。
当我 运行 gulp 命令时,我得到了很多这样的错误:
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'
. . .
如果我在项目文件夹中移动 node_modules,则构建过程成功。如何解决这个问题?
来自 thlorenz(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.