【问题标题】:Laravel Homestead, npm install --no-bin-links errorLaravel Homestead,npm install --no-bin-links 错误
【发布时间】:2017-03-24 19:36:06
【问题描述】:

我正在为一个全新的 Laravel 5.3 应用程序使用全新的 Homestead(盒子版本 0.5)。主机操作系统是 Windows 10。

运行npm install --no-bin-links时出现此错误

npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated graceful-fs@1.2.3: graceful-fs v3.0.0 and before will fail on node releases >= v7.0. Please update to graceful-fs@^4.0.0 as soon as possible. Use 'npm ls graceful-fs' to find it in the tree.
npm ERR! Linux 4.4.0-22-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-bin-links"
npm ERR! node v5.12.0
npm ERR! npm  v3.8.6

npm ERR! Maximum call stack size exceeded
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR! /home/vagrant/t1/t1/npm-debug.log

npm-debug.log

.........
71199 silly build replace-ext@0.0.1
71200 silly build vinyl@1.2.0
71201 silly build require-dir@0.3.1
71202 silly build require-directory@2.1.1
71203 silly build require-main-filename@1.0.1
71204 silly build resolve@1.1.7
71205 silly build rechoir@0.6.2
71206 silly build resolve-url@0.2.1
71207 silly build rev-hash@1.0.0
71208 silly build rev-path@1.0.0
71209 silly build right-align@0.1.3
71210 verbose stack RangeError: Maximum call stack size exceeded
71210 verbose stack     at process.stderr (internal/process/stdio.js:23:46)
71210 verbose stack     at isTTY (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/progress-bar.js:11:17)
71210 verbose stack     at Object.ProgressBar.show (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/progress-bar.js:132:8)
71210 verbose stack     at Object.ProgressBar.pulse (/usr/lib/node_modules/npm/node_modules/npmlog/node_modules/gauge/progress-bar.js:124:8)
71210 verbose stack     at EventEmitter.log.emitLog (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:178:40)
71210 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:170:8)
71210 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:231:21)
71210 verbose stack     at tracker.(anonymous function) [as silly] (/usr/lib/node_modules/npm/node_modules/npmlog/log.js:79:19)
71210 verbose stack     at module.exports (/usr/lib/node_modules/npm/lib/install/action/build.js:8:7)
71210 verbose stack     at actions.(anonymous function) (/usr/lib/node_modules/npm/lib/install/actions.js:48:12)
71211 verbose cwd /home/vagrant/t1/t1
71212 error Linux 4.4.0-22-generic
71213 error argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-bin-links"
71214 error node v5.12.0
71215 error npm  v3.8.6
71216 error Maximum call stack size exceeded
71217 error If you need help, you may report this error at:
71217 error     <https://github.com/npm/npm/issues>
71218 verbose exit [ 1, true ]

没有--no-bin-links 它可以工作(当然如果不在共享文件夹内)

更新了 node 和 npm (6.9.1, 3.10.8),同样的问题。

【问题讨论】:

  • 有点晚了,你解决了吗?如何?我也是这种情况……
  • @andcl85 不,我只是在主机上使用了 npm(和artisan serveiirc),同时仍在使用 Homestead 作为数据库。后来我改用yarn,yarn --no-bin-links 似乎工作正常。
  • 谢谢。顺便说一句,我开发了一种方法来使用 Homestead 使其全部工作;)。我在答案中解释它。

标签: laravel npm vagrant npm-install homestead


【解决方案1】:

你可以试试这个,因为它是我常用的系统:

> npm install --no-bin-links
> npm install --no-bin-links
> npm rebuild node-sass

第一个npm install 通常会出现“超出最大调用堆栈大小”的错误。第二个npm install 从它停止的地方继续并完成安装。 node-sass 通常此时已损坏,因此 npm rebuild 修复了 node-sass 安装。

【讨论】:

    【解决方案2】:

    我开发了一个特殊的方法来让它全部工作。以下是基本步骤:

    • 首先,从 Vagrant 共享文件夹中创建一个目录。例如,它可能是“/home/vagrant/node”。
    • 就在那里,我们将从我们的 Laravel 安装中复制 package.json 文件来告诉 npm 要安装什么...请注意,最近创建的“节点”目录在 Unix 系统中,什么都没有与我们的 Windows 主机有关(因为它不是两者之间共享文件夹的一部分)。
    • 第三,我们将运行 npm install 命令(不带 --no-bin-links 选项,因为 Unix 支持符号链接。应该没有错误;)
    • 最后,我们将 'node_modules' 目录移回我们的 Laravel 安装文件夹(共享文件夹),但已从控制台运行 vagrant up 命令在 Windows 主机中具有管理员权限。否则,尝试移动创建的符号链接会导致错误。

    这一切都可以正常工作,因为它是服务于 Laravel 应用程序的 Unix 机器。 此过程将帮助您顺利安装 Laravel Mix。

    干杯!

    【讨论】:

    • 嗯。如果它允许在以管理员身份运行时移动符号链接,它不能只是在这里创建它们而不移动吗?每次要添加软件包时都这样做似乎很不方便 :) 也许至少可以自动化,例如使用 npm 预安装脚本。但我认为最简单的解决方案就是切换到 yarn :) 它还具有不错的功能,例如 yarn.lock 和更快的安装。 (只需在项目根目录的 after.sh 中添加命令 yarnpkg.com/en/docs/install#linux-tab 即可安装到 Homestead)
    • 我的经验是,一旦安装,每一个连续的 npm install 命令都不会抛出错误,从而产生最佳解决方案。添加nwe包时无需每次都这样做;)
    猜你喜欢
    • 2016-12-30
    • 1970-01-01
    • 2021-04-25
    • 2019-11-22
    • 1970-01-01
    • 1970-01-01
    • 2021-04-12
    • 1970-01-01
    相关资源
    最近更新 更多