尝试并发运行(npm ERR!代码 ELIFECYCLE npm ERR!)

贾里德·麦凯

我正在尝试创建一个从 API 获取数据的全栈节点和 Vue 应用程序。我遇到了一个问题,我试图同时运行客户端和服务器,但代码遇到错误。如果我对这个问题的结构有误,请多多包涵,因为我对编码还很陌生!

这是以下错误日志:

[0] Error occurred when executing command: npm run server
[0] Error: spawn cmd.exe ENOENT
[0]     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[0]     at onErrorNT (internal/child_process.js:469:16)
[0]     at processTicksAndRejections (internal/process/task_queues.js:84:21)     
[1] Error occurred when executing command: npm run client
[1] Error: spawn cmd.exe ENOENT
[1]     at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
[1]     at onErrorNT (internal/child_process.js:469:16)
[1]     at processTicksAndRejections (internal/process/task_queues.js:84:21)
[1] npm run client exited with code -4058
[0] npm run server exited with code -4058
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `concurrently "npm run server" "npm run client"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

据我所知,程序运行良好,直到它到达我的 package.json 中的“dev”脚本:

{
  "name": "apex-tracker",
  "version": "1.0.0",
  "description": "Apex Legends user statistics tracker",
  "main": "server.js",
  "scripts": {
    "start": "node server",
    "server": "nodemon server",
    "client": "npm run serve --prefix client",
    "dev": "concurrently \"npm run server\" \"npm run client\""
  },
  "author": "Jared Mackay",
  "license": "MIT",
  "dependencies": {
    "concurrently": "^5.0.1",
    "dotenv": "^8.2.0",
    "express": "^4.17.1",
    "morgan": "^1.9.1",
    "node-fetch": "^2.6.0"
  },
  "devDependencies": {
    "nodemon": "^2.0.2"
  }
}

在出现错误之前,npm run server command当我运行 .

这是我试图与客户端一起运行的 server.js:

const express = require('express');
const morgan = require('morgan');
const dotenv = require('dotenv');

//Load configuration file
dotenv.config({ path: './config.env' })

const app = express();

//Develper logging
if (process.env.NODE_ENV === 'development') {
    app.use(morgan('dev'));
}

//Profile routes
app.use('/api/v1/profile', require('./routes/profile'));

const port=process.env.PORT || 8000;

app.listen(port, () => {
    console.log(`Server running on ${process.env.NODE_ENV} mode on port ${port}`);
});

我试过清除 npm 缓存、删除和重新安装node-modules以及package-lock.json,但这产生了更多问题而不是修复它们。我不得不恢复到旧的 git commit,现在我被卡住了。

我不认为这个路由 .js 文件是一个问题,但这里只是为了防止 profile.js:

const express = require('express');
const router = express.Router();
const fetch = require('node-fetch');

router.get('/:platform/:gamertag', async (req, res) => {
    try {
        const headers  = {
            'TRN-Api-Key': process.env.TRACKER_API_KEY
        }

        const { platform, gamertag } = req.params;

        const response = await fetch(
            `${process.env.TRACKER_API_URL}/profile/${platform}/${gamertag}`, 
            {
                headers
            }
        );

        const data = await response.json();

        if(data.errors && data.errors.length > 0) {
            return res.status(404).json({
                message: 'Profile Not Found'
            });

        }

        res.json(data);
    }   catch (err) {
        console.error(err);
        res.status(500).json({
            message: 'Server Error'
        });
    }
});

module.exports = router;

先感谢您!

丹尼尔·W。
spawn cmd.exe ENOENT

您的程序不知道在哪里可以找到cmd.exe

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

什么是npm ERR!代码ELIFECYCLE?

调试npm ERR!代码ELIFECYCLE npm ERR!errno 1

npm ERR!代码ELIFECYCLE(开始发行)

npm ERR!运行npm install时的代码ELIFECYCLE

运行“ npm run build”后收到npm错误:npm ERR!代码ELIFECYCLE npm ERR!错误2

npm ERR!代码ELIFECYCLE npm后安装脚本

npm run build给出npm ERR!代码ELIFECYCLE

如何解决npm错误“ npm ERR!代码ELIFECYCLE”

如何解决节点服务器错误,npm ERR!代码ELIFECYCLE npm ERR!errno 1?

npm ERR!天蓝色devops中的代码ELIFECYCLE无法使其运行

如何解决错误:迁移MD5校验和失败[1] npm ERR!代码ELIFECYCLE npm ERR!errno 1

我该如何解决'npm ERR!npm启动期间Project.js中的代码ELIFECYCLE'

我启动npm时遇到了这个问题:npm ERR!代码ELIFECYCLE

Npm ERR!代码EPERM

npm ERR!代码ELIFECYCLE-无法启动开发服务器

如何解决 Linux 中的“npm ERR!code ELIFECYCLE”错误?

npm安装不起作用| npm ERR!路径 npm ERR!代码 npm ERR!errno | npm ERR!syscall | npm ERR!天生的

npm ERR!代码ERR_TLS_CERT_ALTNAME_INVALID

npm install会给出“ npm ERR!代码ENOTFOUND'错误

npm 错误!代码 ENOLOCAL npm ERR!无法安装

npm 错误!代码 ENOENT npm ERR!系统调用重命名

npm -g ERR!外来的

npm ERR!过早关闭

npm 安装不起作用:“npm ERR!代码 ERR_SSL_WRONG_VERSION_NUMBER”

`npm install npm`给出gyp ERR和npm ERR

呃!运行npm start时输入代码ELIFECYCLE

安装角度通知图标时,npm ERR代码ENOSELF

npm ERR!代码UNABLE_TO_GET_ISSUER_CERT_LOCALLY

npm ERR!安装时代码Z_BUF_ERROR