Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/442.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 节点应用程序的Heroku部署返回节点waf:未找到_Javascript_Node.js_Typescript_Heroku_Deployment - Fatal编程技术网

Javascript 节点应用程序的Heroku部署返回节点waf:未找到

Javascript 节点应用程序的Heroku部署返回节点waf:未找到,javascript,node.js,typescript,heroku,deployment,Javascript,Node.js,Typescript,Heroku,Deployment,我试图通过将Heroku连接到我的Github存储库并部署主分支,将Node.js应用程序部署到Heroku 我尝试了许多不同的方法来部署我的应用程序,但都返回相同的错误 具体的生成日志可在下面找到: -----> Node.js app detected -----> Creating runtime environment NPM_CONFIG_LOGLEVEL=error NODE_ENV=production NODE_MODULES_CACHE=tru

我试图通过将Heroku连接到我的Github存储库并部署主分支,将Node.js应用程序部署到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):  12.16.1
       engines.npm (package.json):   6.13.4
       engines.yarn (package.json):  1.19.1

   Resolving node version 12.16.1...
   Downloading and installing node 12.16.1...
   npm 6.13.4 already installed with node
   Resolving yarn version 1.19.1...
   Downloading and installing yarn (1.19.1)...
   Installed yarn 1.19.1

-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.19.1
       warning package.json: No license field
       warning No license field
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       error /tmp/build_6239d6c68cba3cabeb950e607f13b16d/node_modules/node-base64: Command failed.
       Exit code: 127
       Command: ./install.sh
       Arguments: 
       Directory: /tmp/build_6239d6c68cba3cabeb950e607f13b16d/node_modules/node-base64
       Output:
       ./install.sh: 3: ./install.sh: node-waf: not found
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/

   Love,
   Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed
{
  "engines": {
    "node": "12.16.1",
    "npm": "6.13.4",
    "yarn": "1.19.1"
  },
  "scripts": {
    "start": "tsc && node dist/app.js"
  },
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "express-validator": "^6.4.0",
    "jsonwebtoken": "^8.5.1",
    "jwt": "^0.2.0",
    "mongoose": "^5.7.11",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "typescript": "^3.8.3"
  },
  "devDependencies": {
    "@types/bcryptjs": "^2.4.2",
    "@types/cors": "^2.8.6",
    "@types/express": "^4.17.2",
    "@types/jsonwebtoken": "^8.3.5",
    "@types/mongoose": "^5.5.32",
    "@types/passport-jwt": "^3.0.3",
    "@types/passport-local": "^1.0.33",
    "prettier": "1.19.1",
    "tslint": "^5.20.1"
  }
}
我的
package.json
文件可以在下面找到:

-----> 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):  12.16.1
       engines.npm (package.json):   6.13.4
       engines.yarn (package.json):  1.19.1

   Resolving node version 12.16.1...
   Downloading and installing node 12.16.1...
   npm 6.13.4 already installed with node
   Resolving yarn version 1.19.1...
   Downloading and installing yarn (1.19.1)...
   Installed yarn 1.19.1

-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.19.1
       warning package.json: No license field
       warning No license field
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       [4/4] Building fresh packages...
       error /tmp/build_6239d6c68cba3cabeb950e607f13b16d/node_modules/node-base64: Command failed.
       Exit code: 127
       Command: ./install.sh
       Arguments: 
       Directory: /tmp/build_6239d6c68cba3cabeb950e607f13b16d/node_modules/node-base64
       Output:
       ./install.sh: 3: ./install.sh: node-waf: not found
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys

   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/

   Love,
   Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed
{
  "engines": {
    "node": "12.16.1",
    "npm": "6.13.4",
    "yarn": "1.19.1"
  },
  "scripts": {
    "start": "tsc && node dist/app.js"
  },
  "dependencies": {
    "bcryptjs": "^2.4.3",
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "express-validator": "^6.4.0",
    "jsonwebtoken": "^8.5.1",
    "jwt": "^0.2.0",
    "mongoose": "^5.7.11",
    "passport": "^0.4.0",
    "passport-jwt": "^4.0.0",
    "passport-local": "^1.0.0",
    "typescript": "^3.8.3"
  },
  "devDependencies": {
    "@types/bcryptjs": "^2.4.2",
    "@types/cors": "^2.8.6",
    "@types/express": "^4.17.2",
    "@types/jsonwebtoken": "^8.3.5",
    "@types/mongoose": "^5.5.32",
    "@types/passport-jwt": "^3.0.3",
    "@types/passport-local": "^1.0.33",
    "prettier": "1.19.1",
    "tslint": "^5.20.1"
  }
}
  • 我已经尝试将确切的引擎版本添加到package.json中
  • 我已经试着把纱线拆下来了
  • 我尝试将typescript作为依赖项安装,而不是作为全局包安装
  • 我不知道如何手动安装node-base64/node-waf依赖项

感谢您提供的所有潜在解决方案。

TL;DR.删除
jwt
并使用
jsonwebtoken

详情: 作为一个依赖项。jwt和node-base64都不再维护。在引擎盖下,node-base64使用已弃用的
node waf
。因此,对不推荐使用的包的调用循环导致了您遇到的失败。将
jwt
替换为
jsonwebtoken
将解决此问题


在不使用jwt的情况下,
节点waf也可能遇到问题。查看此问题以帮助您解决此问题。

您似乎正在同时使用纱线和npm。你有什么理由不能只使用纱线,至少在你的heroku env上?这可能会对你有帮助。接得好,我没有理由不能只用纱线。我在一个不同于我目前使用的设备上启动了这个项目(这就是为什么纱线和npm混合在一起的原因)。我曾尝试查找package-lock.json文件,但它不存在,然而,warn.lock文件确实存在,但我之前已尝试删除此文件,但它对我没有帮助。有没有其他文件告诉Heroku使用NPM?我是否应该从package.json文件中删除npm引擎声明?实际上,深入查看package.json和错误日志,我认为问题来自
jwt
。您可以尝试使用
jsonwebtoken
而不是
jwt
。如果可以的话,请告诉我,这样我就可以帮助其他可能有类似问题的人。我已经删除了jwt包,部署成功。我记得我以前试过使用jwt,但后来改用jsonwebtoken,你可以通过查看我的package.json来判断。非常感谢你的帮助,我真的不明白你是怎么发现这是个问题的?你的回答确实解决了我的问题,所以你可以让它回答。很高兴它帮助你解除了障碍。