Почему json-server не работает должным образом?
Посли запуска npm с установкой json-server было введена команда json-server db.json на что терминал выдал 'bash: json-server: command not found'(Пробовал устанавливать json-server глобально не помогло)
MacBook-Pro-Aleksandr:Food_dist-2 aleksandr$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help json` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (food_dist-2)
version: (1.0.0)
description:
git repository:
keywords:
author:
license: (ISC)
About to write to /Applications/MAMP/htdocs/Food_dist-2/package.json:
{
"name": "food_dist-2",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"json-server": "^0.16.1"
},
"dependencies": {},
"description": ""
}
Is this OK? (yes) y
MacBook-Pro-Aleksandr:Food_dist-2 aleksandr$ npm i json-server --save-dev
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
+ [email protected]
updated 2 packages and audited 234 packages in 5.208s
1 package is looking for funding
run `npm fund` for details
found 2 low severity vulnerabilities
run `npm audit fix` to fix them, or `npm audit` for details
MacBook-Pro-Aleksandr:Food_dist-2 aleksandr$ json-server db.json
bash: json-server: command not found
MacBook-Pro-Aleksandr:Food_dist-2 aleksandr$
Ответы (2 шт):
Автор решения: Valek
→ Ссылка
Запустите Windows PowerShell с параметром «Запуск от имени администратора». Только члены группы «Администраторы» на компьютере могут изменять политику выполнения.
Включите запуск неподписанных скриптов, введя:
set-executionpolicy remotesigned Это позволит запускать неподписанные сценарии, которые вы пишете на локальном компьютере, и подписанные сценарии из Интернета.
Автор решения: Vladimir Pak
→ Ссылка
Столкнулся на mac с такой же проблемой.
Запустил в итоге вот так:
$ npx json-server --watch db.json