node.js - 当 node_modules 文件夹是符号链接(symbolic link)时 browserify-shim 错误

标签 node.js gulp browserify node-modules browserify-shim

在生产服务器上,node_modules 文件夹是用于持续部署目的的符号链接(symbolic link)。 当我运行 gulp 命令时,出现了很多这样的错误: 错误:解析文件时无法在/home/web/www/persist/node_modules/jquery-ui/jquery-ui.js 的 package.json 中找到 browserify-shim 配置部分:/home/web/www/persist/node_modules/jquery-ui/jquery-ui.js] 文件名:'/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.js - 当 node_modules 文件夹是符号链接(symbolic link)时 browserify-shim 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36559378/

相关文章:

javascript - 使用 Mongoose 通过传递选项 JSON 来过滤数据 DB 级别

javascript - 使用 Webpack 和 Typescript 将模块暴露给全局 Window 对象

javascript - 如何从 babel 处理的 rollup 包中删除 use strict

gulp - Vueify - 需要 *.vue 文件返回空对象

javascript - nodejs .env 变量显示未定义

javascript - 如何对bundle.js文件进行分块?

javascript - Grunt Uglify - 如何创建用于调试的源映射?

node.js - 更改 NginX 位置 block 时 Express 应用程序无法获取静态内容

typescript - Browserify + typescript

javascript - 将 watchify 与 babelify 一起使用