Laravel Homestead npm install error 有解决办法吗?

Is there a solution for npm install error in Laravel Homestead?

我想做的只是在新安装的 Laravel 应用程序中执行 npm install 命令,但我不断收到错误。

在谷歌搜索了两天并尝试了我发现的所有可能的 npm 安装错误解决方案之后,我决定再尝试一次重新安装所有东西,希望能解决我的 npm install 问题,但不幸的是,这也没有帮助.

我尝试删除 node_modules,
清理 npm 缓存,
须藤 npm 安装,
sudo npm install --no-bin-links,
更新节点和 npm 但都已经是最新版本了,
根据我在互联网上看到的一些 posts 更改 VagrantFile(这从来没有用过,因为当我使用 vagrant up 时我会得到一个错误),
重新安装一切,
运行 bash 作为管理员,

我什至不记得我所做的一切。这真的很累。

我的日志有 17k+ 行长。我只是 post 发生错误的最后一部分。

17734 verbose stack Error: ENOENT: no such file or directory, open '/home/vagrant/code/vue-test/node_modules/yargs/node_modules/yargs-parser/package.json.2655513948'
17735 verbose cwd /home/vagrant/code/vue-test
17736 verbose Linux 4.15.0-54-generic
17737 verbose argv "/usr/bin/node" "/usr/bin/npm" "install" "--no-bin-links"
17738 verbose node v12.5.0
17739 verbose npm  v6.10.1
17740 error path /home/vagrant/code/vue-test/node_modules/yargs/node_modules/yargs-parser/package.json.2655513948
17741 error code ENOENT
17742 error errno -2
17743 error syscall open
17744 error enoent ENOENT: no such file or directory, open '/home/vagrant/code/vue-test/node_modules/yargs/node_modules/yargs-parser/package.json.2655513948'
17745 error enoent This is related to npm not being able to find a file.
17746 verbose exit [ -2, true ]

我最后的希望是询问是否有人对此有解决方案,或者我应该放弃 Homestead。

过去两天我一直在努力解决完全相同的问题,除了我 运行 在 macOS (10.14) 上。使用 yarn 而不是 npm 终于让我能够正确编译(参见安装包的文档:https://yarnpkg.com/lang/en/docs/install/#alternatives-stable). It is a package manager that can use the same package.json entry point as npm, and you can simply try to run yarn install to perform the same action as npm install (for more in depth comparison between the commands, you can check out this link: https://yarnpkg.com/lang/en/docs/migrating-from-npm/)。可以肯定的是,它没有解决 npm 的主要问题,但至少它应该允许您在等待更合理的答案的同时处理您的项目。

我为避免此错误所做的工作是在 host-machine 中 npm install,而不是通过 vagrant ssh 在来宾上。 Windows 锁定我研究过的文件似乎是个问题。我为绕过它所做的是:

  1. vagrant halt
  2. 在您的主机 (Windows) 中,转到您在 homestead.yaml 文件中 set-up 的网站的共享文件夹。
  3. 从文件夹中打开 cmdgit bash(以管理员身份)(Shift+右键单击或 cd 进入文件夹)和 运行 npm install .

我遇到了同样的问题

npm install --force

对我有用

我什么都试过了..唯一对我有用的是在我的 linux 盒子上设置一个 samba 服务器...由此我可以直接在我的 [=14= 上编辑文件] 机器..

希望这对您有所帮助

vagrant halt

然后 运行 npm,安装 && npm 运行 dev,它对我有用

我搜索了很长时间的解决方案,但没有任何效果。

有效的方法是在主机上安装 nodejs,然后在项目文件夹中 运行ning npm install,然后在客户机的项目中 运行ning npm 运行 ...文件夹