繁体   English   中英

在heroku上部署应用程序时出现过时的纱线锁文件错误

[英]Outdated yarn lockfile error on deploying app on heroku

我已经成功注册了 Heroku,但是当我git push并运行该应用程序时,它说

Application error. An error occurred in the application and your page could not be served. If you are the application owner, check your logs for details. You can do this from the Heroku CLI with the command

然后,我从 Web 浏览器转到 Heroku,在“手动部署”下,单击“部署分支”并获得以下错误列表:

    -----> Node.js app detected

    -----> Creating runtime environment

           NPM_CONFIG_LOGLEVEL=error
           NODE_ENV=production
           NODE_MODULES_CACHE=true
           NODE_VERBOSE=false

    -----> Installing binaries
           engines.node (package.json):  unspecified
           engines.npm (package.json):   unspecified (use default)
           engines.yarn (package.json):  unspecified (use default)

           Resolving node version 10.x...
           Downloading and installing node 10.15.1...
           Using default npm version: 6.4.1
           Resolving yarn version 1.x...
           Downloading and installing yarn (1.14.0)...
           Installed yarn 1.14.0

    -----> Building dependencies
           Installing node modules (yarn.lock)
           yarn install v1.14.0
           [1/4] Resolving packages...
           error Your lockfile needs to be updated, but yarn was run with `--frozen-lockfile`.
           info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
    -----> Build failed
     !     Outdated Yarn lockfile
           Your application contains a Yarn lockfile (yarn.lock) which does not
           match the dependencies in package.json. This can happen if you use npm
           to install or update a dependency instead of Yarn.
           Please run the following command in your application directory and check
           in the new yarn.lock file:
           $ yarn install
           $ git add yarn.lock
           $ git commit -m "Updated Yarn lockfile"
           $ git push heroku master

           https://kb.heroku.com/why-is-my-node-js-build-failing-because-of-an-outdated-yarn-lockfile
     !     Push rejected, failed to compile Node.js app.
     !     Push failed

有人可以给我一些指点吗? 我不知道为什么它提到纱线。 这是我的 package.json:

    {
      "name": "tictacttoe",
      "version": "0.1.0",
      "private": true,
      "engines": {
        "node": "v10.13.0",
        "npm": "6.4.1"
      },
      "dependencies": {
        "react": "^16.7.0",
        "react-dom": "^16.7.0",
        "react-scripts": "2.1.3"
      },
      "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
      },
      "eslintConfig": {
        "extends": "react-app"
      },
      "browserslist": [
        ">0.2%",
        "not dead",
        "not ie <= 11",
        "not op_mini all"
      ],
      "devDependencies": {
        "webpack": "^4.19.1",
        "webpack-dev-server": "^3.1.14"
      }
    }

我不确定这是由于heroku还是由于您的末尾一些错误的配置...但是基本上heroku正在运行yarn来安装您的依赖项,并且由于您没有yarn.lock (或有一个过时的),所以导致错误。

尝试在系统上全局安装yarn并在项目的根目录上运行yarn。 之后,如果您提交yarn.lock文件,它可能会起作用。

AFAIK,heroku从其中是否包含yarn.lockpackage-lock.json来检测您的包管理器。 因此,您应该删除yarn.lock ,或者通过在项目的根目录中运行yarn来更新它。

这是因为 Heroku 无法找到更新的纱线锁文件。 运行以下命令,您应该就可以开始了。

yarn install 
git add yarn.lock 
git commit -m "updating yarn" && git push
git push heroku master

暂无
暂无

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

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