【问题标题】:sh: 1: del: not foundsh:1:del:未找到
【发布时间】:2021-04-07 21:25:18
【问题描述】:

我想知道你是否可以帮助我 Heroku 部署失败。一直在查看其他类似的堆栈溢出帖子并更改 package.json 文件尝试对其他人没有运气的解决方案。我认为这不是端口问题,但可能是 package.json 问题或完全不同的问题。非常感谢任何帮助、提示或建议!

Heroku 日志:

 -----> Build
        Running build
        
        > honeyman-designs@1.0.0 build /tmp/build_a9c0d0bf
        > del dist && babel backend -d dist  && cd frontend && npm install && npm run build
   
 sh: 1: del: not found
 npm ERR! code ELIFECYCLE
 npm ERR! syscall spawn
 npm ERR! file sh
 npm ERR! errno ENOENT
 npm ERR! honeyman-designs@1.0.0 build: `del dist && babel backend -d dist  && cd frontend && npm                     
 install && npm run build`
 npm ERR! spawn ENOENT
 npm ERR! 
 npm ERR! Failed at the honeyman-designs@1.0.0 build script.
 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
 npm ERR! A complete log of this run can be found in:
 npm ERR!     /tmp/npmcache.tyCCY/_logs/2020-12-31T15_09_59_938Z-debug.log

这是我的 package.json 文件:

 {
   "name": "honeyman-designs",
   "version": "1.0.0",
   "description": "",
   "main": "index.js",
   "dependencies": {
     "body-parser": "^1.19.0",
     "dotenv": "^8.2.0",
     "express": "^4.17.1",
     "jsonwebtoken": "^8.5.1",
     "mongoose": "^5.10.15",
     "react-paypal-button-v2": "^2.6.2"
   },
   "devDependencies": {
     "@babel/cli": "^7.12.1",
     "@babel/core": "^7.12.3",
     "@babel/node": "^7.12.1",
     "@babel/preset-env": "^7.12.1",
     "nodemon": "^2.0.6"
   },
   "scripts": {
     "start": "nodemon --watch backend --exec babel-node backend/server.js",
     "build": "rd /s dist && babel backend -d dist  && cd frontend && npm install && npm run build",
     "heroku-postbuild-x": "npm run build && cd frontend && npm install && npm run build"
   },
   "repository": {
     "type": "git",
     "url": "git+https://github.com/codegreene93/HoneymanDesigns.git"
   },
   "author": "",
   "license": "ISC",
   "bugs": {
     "url": "https://github.com/codegreene93/HoneymanDesigns/issues"
   },
   "homepage": "https://github.com/codegreene93/HoneymanDesigns#readme",
   "engines": {
     "node": "12.4.0",
     "npm": "6.14.10"
   }
 }

我已尝试清除缓存并删除并重新安装 node_modulespackage-lock.json

我已经更新了 nodenpm 版本

我使用的是 Windows 10,我也试过这样:

del dist && babel backend -d dist && cd frontend && npm install && npm run build

rd /s dist && babel backend -d dist && cd frontend && npm install && npm run build

rm -r dist && babel backend -d dist && cd frontend && npm install && npm run build

它们都没有运行得到相同的 sh:1 错误

server.js 文件:

 app.listen(config.PORT, () => {
   console.log('Server started at http://localhost:5000');
 });

config.js

 PORT: process.env.PORT || 5001

【问题讨论】:

    标签: node.js heroku npm npm-install


    【解决方案1】:

    rddelWindows 命令,但 Heroku 不运行 Windows。您将无法在 Heroku 上使用这些命令。

    我建议使用跨平台替代方案,例如 rimraf 插入特定于平台的命令,以便您的脚本可以在本地开发环境和托管环境中正常运行。

    将它添加到您的依赖项中,然后使用类似的东西

    npx rimraf dist && babel backend -d dist  && cd frontend && npm install && npm run build
    

    【讨论】:

      猜你喜欢
      • 2016-08-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-15
      • 1970-01-01
      • 2021-10-05
      • 2021-03-26
      • 1970-01-01
      相关资源
      最近更新 更多