2020-02-19_10:16:43.61962 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 3000.[39m[22m
2020-02-19_10:16:43.69223 [1m[22m
2020-02-19_10:16:43.69224 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61CSleep 60 secs. before restart due to previous errors...
2020-02-19_10:17:01.59386 Sleep 3 secs. before restart due to previous errors...
2020-02-19_10:17:05.13303
2020-02-19_10:17:05.13306 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:17:05.13306 > react-scripts start
2020-02-19_10:17:05.13306
2020-02-19_10:17:06.76649 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 3000.[39m[22m
2020-02-19_10:17:06.86468 [1m[22m
2020-02-19_10:17:06.86468 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:20:51.79461 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:20:51.79461 > PORT=53178 react-scripts start
2020-02-19_10:20:51.79462
2020-02-19_10:20:53.37256 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 53178.[39m[22m
2020-02-19_10:20:53.43467 [1m[22m
2020-02-19_10:20:53.43468 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:22:20.08950 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:22:20.08951 > static-server -p 53178 react-scripts start
2020-02-19_10:22:20.08951
2020-02-19_10:22:20.09585 sh: static-server: command not found
2020-02-19_10:22:20.09965 [37;40mnpm[0m [0m[31;40mERR![0m [0m[35mcode[0m ELIFECYCLE
2020-02-19_10:22:20.10001 [0m[37;40mnpm[0m [0m[31;40mERR![0m [0m[35msyscall[0m spawn
2020-02-19_10:22:20.10450 [0m[37;40mnpm[0m [0m[31;40mERR![0m [0m[35mfile[0m sh
2020-02-19_10:22:20.10467 [0m[37;40mnpm[0m [0m[31;40mERR![0m [0m[35merrno[0m ENOENT
2020-02-19_10:22:20.10495 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m my-app@0.1.0 start: `static-server -p 53178 react-scripts start`
2020-02-19_10:22:20.10630 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m spawn ENOENT
2020-02-19_10:22:20.10649 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m
2020-02-19_10:22:20.10670 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m Failed at the my-app@0.1.0 start script.
2020-02-19_10:22:20.10690 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m This is probably not a problem with npm. There is likely additional logging output above.
2020-02-19_10:22:20.10706 [0m
2020-02-19_10:22:20.11301 [37;40mnpm[0m [0m[31;40mERR![0m[35m[0m A complete log of this run can be found in:
2020-02-19_10:22:20.11314 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m /home/c17400/youdecide.na4u.ru/.npm/_logs/2020-02-19T10_22_20_108Z-debug.log
2020-02-19_10:22:20.11327 [0mSleep 3 secs. before restart due to previous errors...
2020-02-19_10:22:24.99077
2020-02-19_10:22:24.99081 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:22:24.99081 > static-server -p 53178 react-scripts start
2020-02-19_10:22:24.99081
2020-02-19_10:22:24.99863 sh: static-server: command not found
2020-02-19_10:22:25.00130 [37;40mnpm[0m [0m[31;40mERR![0m [0m[35mcode[0m ELIFECYCLE
2020-02-19_10:22:25.00135 [0m[37;40mnpm[0m [0m[31;40mERR![0m [0m[35msyscall[0m spawn
2020-02-19_10:22:25.00162 [0m[37;40mnpm[0m [0m[31;40mERR![0m [0m[35mfile[0m sh
2020-02-19_10:22:25.00172 [0m[37;40mnpm[0m [0m[31;40mERR![0m [0m[35merrno[0m ENOENT
2020-02-19_10:22:25.00187 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m my-app@0.1.0 start: `static-server -p 53178 react-scripts start`
2020-02-19_10:22:25.00284 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m spawn ENOENT
2020-02-19_10:22:25.00289 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m
2020-02-19_10:22:25.00304 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m Failed at the my-app@0.1.0 start script.
2020-02-19_10:22:25.00311 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m This is probably not a problem with npm. There is likely additional logging output above.
2020-02-19_10:22:25.00321 [0m
2020-02-19_10:22:25.00826 [37;40mnpm[0m [0m[31;40mERR![0m[35m[0m A complete log of this run can be found in:
2020-02-19_10:22:25.00826 [0m[37;40mnpm[0m [0m[31;40mERR![0m[35m[0m /home/c17400/youdecide.na4u.ru/.npm/_logs/2020-02-19T10_22_25_003Z-debug.log
2020-02-19_10:22:25.00826 [0mSleep 60 secs. before restart due to previous errors...
2020-02-19_10:23:25.88808
2020-02-19_10:23:25.88810 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:23:25.88810 > react-scripts start
2020-02-19_10:23:25.88811
2020-02-19_10:23:27.51654 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 3000.[39m[22m
2020-02-19_10:23:27.59038 [1m[22m
2020-02-19_10:23:27.59038 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:25:04.58138 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:25:04.58139 > $ set -a $ PORT=53178 & react-scripts start
2020-02-19_10:25:04.58139
2020-02-19_10:25:04.59008 sh: $: command not found
2020-02-19_10:25:06.50080 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 3000.[39m[22m
2020-02-19_10:25:06.58755 [1m[22m
2020-02-19_10:25:06.58755 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:25:34.49055 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:25:34.49055 > react-scripts start
2020-02-19_10:25:34.49056
2020-02-19_10:25:36.00267 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 3000.[39m[22m
2020-02-19_10:25:36.08400 [1m[22m
2020-02-19_10:25:36.08401 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:46:14.44855 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:46:14.44855 > PORT=53178 react-scripts start
2020-02-19_10:46:14.44855
2020-02-19_10:46:16.12685 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 53178.[39m[22m
2020-02-19_10:46:16.18577 [1m[22m
2020-02-19_10:46:16.18577 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:50:28.71509 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:50:28.71509 > react-scripts start
2020-02-19_10:50:28.71510
2020-02-19_10:50:30.34448 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 53178.[39m[22m
2020-02-19_10:50:30.48303 [1m[22m
2020-02-19_10:50:30.48304 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:51:45.18849 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:51:45.18849 > set PORT=53178 && react-scripts start
2020-02-19_10:51:45.18850
2020-02-19_10:51:46.77697 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 53178.[39m[22m
2020-02-19_10:51:46.84017 [1m[22m
2020-02-19_10:51:46.84018 [1mWould you like to run the app on another port instead?[22m[0m [0m[2m(Y/n) [22m[61D[61C
2020-02-19_10:59:09.59363 > my-app@0.1.0 start /home/c17400/youdecide.na4u.ru/www
2020-02-19_10:59:09.59364 > cross-env PORT=53178 react-scripts start
2020-02-19_10:59:09.59364
2020-02-19_10:59:11.37022 [2J[3J[H[32m?[39m [1m[33mSomething is already running on port 53178.[39m[22m
2020-02-19_10:59:11.43383 [1m[22m
npm i cross-env
Или используйте npm cross-env (без &&!)
"scripts": {
"start": "cross-env PORT=3006 react-scripts start",
}
Вы можете указать свой порт с помощью process.env.PORT. Это можно сделать, изменив скрипт для запуска в package.json, как показано ниже:
"start": "PORT = 3006 start-scripts start"
Вы также можете создать .envфайл с
PORT=3006
и сохраните его в каталоге вашего проекта.
На Windows с пряжей это работало для меня:
"scripts": {
"start": "set PORT=3006 && react-scripts start",
....
async function getData(url) {
let queryForUrl = url instanceof String && url.length ? url : '/';
const options = {
method: 'POST',
headers: {
'Content-Type' : 'application/json'
}
};
let response = await fetch(queryForUrl, options);
let data = await response.json();
return data;
}
const data = getData();
console.log(data);
Ключевое слово await заставит интерпретатор JavaScript ждать до тех пор, пока промис справа от await не выполнится.
switch (this.options.render) {
case 'value':
label = dataset.data[index];
break;
case 'label':
label = this.chart.config.data.labels[index];
break;
case 'image':
label = this.options.images[index] ? this.loadImage(this.options.images[index]) : '';
break;
case 'percentage':
default:
label = (function() {
return `<span class='customPercents'>${this.getPercentage(dataset, element, index)}%</span>`;
})
break;
}
let response = xhr.onload = (e) => { /* <==== Теперь e.target.result результат вот этой функции, а его мы записываем в response и возвращаем уже его в конечном результате */
let reader = new FileReader();
reader.readAsDataURL(xhr.response);
/* Теперь он результат этой функции и мы возвращаем его ещё раз r.target.result ====> */ return reader.onload = (e) => {
/* Возвращаем r.target.result ====> */ return e.target.result
};
};