简体   繁体   English

考虑到 yarn run serve 在本地机器上工作,如何在使用 Netlify 部署时修复“未找到这些依赖项:”

[英]How to fix "These dependencies were not found:" when deploying with Netlify given that yarn run serve works on local machine

I am setting up a site using Vue.js, yarn and Netlify.我正在使用 Vue.js、yarn 和 Netlify 建立一个站点。 When I run yanr run build on my local machine all goes well.当我在我的本地机器上运行 yanr run build 时一切顺利。 When I deploy though Netlify I get the following issue:当我通过 Netlify 进行部署时,出现以下问题:

5:17:55 PM: failed during stage 'building site': Build script returned non-zero exit code: 1   
5:17:55 PM: * @/views/SignInFlow/Recover.vue in ./src/router.js  
5:17:55 PM: * @/views/SignInFlow/Request.vue in ./src/router.js  
5:17:55 PM: * @/views/SignInFlow/SignIn.vue in ./src/router.js  

In order to fix the issue have tries to:为了解决这个问题,我们尝试:

  1. Clear cache清除缓存
  2. Reinstall node_modules重新安装 node_modules
  3. Run yarn install --save @/views/SignInFlow/Recover.vue in./src/router.js运行 yarn install --save @/views/SignInFlow/Recover.vue in./src/router.js

This is what the router.js paths look like:这是 router.js 路径的样子:

import Vue from "vue";
import Router from "vue-router";
import Home from "@/views/Home.vue";
import Team from "@/views/Team.vue";
import SignIn from "@/views/SignInFlow/SignIn.vue";
import Request from "@/views/SignInFlow/Request.vue";
import Recover from "@/views/SignInFlow/Recover.vue";

Nothing helps没有任何帮助

Paths are correct I am 100% sure.我 100% 确定路径是正确的。

This is what is inside SignIn.vue:这是 SignIn.vue 中的内容:

<template>
  <div
    class="container"
    :class="{'light-background' : !isDarkMode, 'dark-background' : isDarkMode}"
  >
    <Notification v-if="hasText" :text="text"/>
    <RequestAccount/>
    <div class="login">
      <img src="@/assets/DCHQ.svg" v-show="isDarkMode">
      <img src="@/assets/DCHQ-dark.svg" v-show="!isDarkMode">
      <h4 :class="{'light-text' : isDarkMode, 'dark-text' : !isDarkMode}">Sign into Design+Code HQ</h4>
      <form @submit.prevent="onSubmit">
        <input
          type="email"
          placeholder="Email"
          :class="{'light-field' : isDarkMode, 'dark-field' : !isDarkMode}"
          v-model="email"
          required
        >
        <input
          type="password"
          placeholder="Password"
          :class="{'light-field' : isDarkMode, 'dark-field' : !isDarkMode}"
          v-model="password"
          required
        >
        <button>Sign In</button>
      </form>
      <router-link
        to="/recover"
        :class="{'light-link': isDarkMode, 'dark-link' : !isDarkMode}"
      >Forgot your password?</router-link>
      <ThemeSwitch/>
    </div>
  </div>
</template>

<script>
import RequestAccount from "@/components/RequestAccount";
import ThemeSwitch from "@/components/ThemeSwitch";
import Notification from "@/components/Notification";
import { auth } from "@/main";

export default {
  name: "SignIn",
  components: {
    RequestAccount,
    ThemeSwitch,
    Notification
  },
  data() {
    return {
      email: null,
      password: null,
      hasText: false,
      text: ""
    };
  },
  computed: {
    isDarkMode() {
      return this.$store.getters.isDarkMode;
    }
  },
  methods: {
    onSubmit() {
      const email = this.email;
      const password = this.password;

      auth
        .login(email, password, true)
        .then(response => {
          this.$router.replace("/");
        })
        .catch(error => {
          alert("Error: " + error);
        });
    }
  },
  mounted() {
    const params = this.$route.params;

    if (params.userLoggedOut) {
      this.hasText = true;
      this.text = "You have logged out!";
    } else if (params.userRecoveredAccount) {
      this.hasText = true;
      this.text = `A recovery email has been sent to ${params.email}`;
    } else if (params.userRequestedAccount) {
      this.hasText = true;
      this.text = `Your request has been sent to an administator for ${
        params.email
      }`;
    }
  }
};
</script>

<style scoped lang="scss">
.container {
  display: flex;
  justify-content: center;
  align-items: center;

  min-height: 100vh;
}

.login {
  width: 400px;
  text-align: center;
}
</style>

I want to make it possible to deploy my site through Netlify but I have no idea what else to try in order debug the issue.我想让通过 Netlify 部署我的网站成为可能,但我不知道还有什么可以尝试调试问题。

If you have this problem, it means that after a first deploy to Netlify you changed the case of the folder's name's first letter.如果您遇到此问题,则意味着在首次部署到 Netlify 后,您更改了文件夹名称首字母的大小写。 As Netlify memorized it the other way, it won't recognize the new name.由于 Netlify 以另一种方式记住它,因此它不会识别新名称。 So try to replace: @/views/SignInFlow/YourFile.vue with: @/views/signInFlow/YourFile.vue And same for the folder's name.因此,请尝试将: @/views/SignInFlow/YourFile.vue替换为: @/views/signInFlow/YourFile.vue文件夹名称也一样。

If you want the cause of the issue, look here: https://docs.netlify.com/configure-builds/troubleshooting-tips/#case-sensitivity如果您想了解问题的原因,请查看此处: https ://docs.netlify.com/configure-builds/troubleshooting-tips/#case-sensitivity

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM