本文介绍了错误命令失败,退出代码为 1.当我尝试运行纱线时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习 reactjs - nodejs我试图运行服务器所以我安装了yarn、nodemon、express但是当我试图运行它的说法时错误命令失败,退出代码为 1.
I am learning reactjs - nodejsI was trying to run the server so I installed yarn, nodemon, expressbut when I try to run its sayingerror Command failed with exit code 1.
我的错误是
PS D:\react project\ReactManagement-tutorial> yarn dev
yarn run v1.13.0
warning package.json: No license field
$ concurrently --kill-others-on-fail "yarn server" "yarn client"
warning package.json: No license field
warning package.json: No license field
$ nodemon server.js
$ cd client && yarn start
warning ..\package.json: No license field
$ react-scripts start
[1] 'react-scripts'��(��) ���� �Ǵ� �ܺ� ����, ���
��� �� �ִ� ���α�, �Ǵ�
[1] ��ġ ������ �ƴմϴ�.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
error Command failed with exit code 1.
[1] yarn client exited with code 1
--> Sending SIGTERM to other processes..
[0] yarn server exited with code 1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
PS D:\react project\ReactManagement-tutorial>
我的 package.json 是
my package.json is
{
"name": "management",
"version": "1.0.0",
"scripts": {
"client": "cd client && yarn start",
"server": "nodemon server.js",
"dev": "concurrently --kill-others-on-fail \"yarn server\" \"yarn client\""
},
"dependencies": {
"body-parser": "^1.18.3",
"express": "^4.16.4",
"nodemon": "^1.18.10"
},
"devDependencies": {
"concurrently": "^4.1.0"
}
}
和我的 server.js
and its my server.js
const express = require('express');
const bodyParser = require('body-parser'); //서버모듈을위한
const app = express();
const port = process.env.PORT || 5000;
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended:true}));
app.get('/api/hello',(req,res) =>{
res.send({message : 'hello express!'});
});
app.listen(port,()=>console.log(`listening on port ${port}`))
推荐答案
您需要做的很简单:请按照以下步骤操作:
what you need to do is just simple:follow these steps:
- rm -rf node_modules
- 纱线缓存清洁
- 纱线
- 纱线开始
这篇关于错误命令失败,退出代码为 1.当我尝试运行纱线时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!