如何解决“NPM ERR!在NPM退出状态64“错误
我设立本地服务器,我正在我的服务器npm run json:server
但我收到以下错误:
NPM ERR!未能在[email protected] JSON:服务器脚本 'JSON-服务器--watch db.json'。
无法弄清楚如何解决这一问题?
我尝试更新npm update -g
,并没有帮助。也试过npm i -g npm
和安装JSON服务器在本地使用npm i --save-dev json-server
没有帮助
Lenovo-ideapad-990-95IKB:~/Desktop/jsonserver$ **npm run json:server**
> [email protected] json:server /home/zack/Desktop/jsonserver
> **json-server --watch db.json**
Could not find an option or flag "-c".
Usage: pub <command> [arguments]
Global options:
-h, --help Print this usage information.
--version Print pub version.
--[no-]trace Print debugging information when an error occurs.
--verbosity Control output verbosity.
[all] Show all output including internal tracing messages.
[error] Show only errors.
[io] Also show IO operations.
[normal] Show errors, warnings, and user messages.
[solver] Show steps during version resolution.
[warning] Show only errors and warnings.
-v, --verbose Shortcut for "--verbosity=all".
Available commands:
cache Work with the system cache.
deps Print package dependencies.
downgrade Downgrade the current package's dependencies to oldest versions.
get Get the current package's dependencies.
global Work with global packages.
help Display help information for pub.
publish Publish the current package to pub.dartlang.
run Run an executable from a package.
upgrade Upgrade the current package's dependencies to latest versions.
uploader Manage uploaders for a package on pub.dartlang.
version Print pub version.
Run "pub help <command>" for more information about a command.
See for detailed documentation.
npm ERR! Linux 4.19.5-041905-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "json:server"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] json:server: `json-server --watch db.json`
npm ERR! **Exit status 64**
npm ERR!
npm ERR! **Failed at the [email protected] json:server script 'json-server --watch db.json'.**
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jsonserver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! json-server --watch db.json
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs jsonserver
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls jsonserver
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/zack/Desktop/jsonserver/npm-debug.log```
这里的package.json:
{
"name": "jsonserver",
"version": "1.0.0",
"description": "REST API Tracker",
"main": "index.js",
"scripts": {
"json:server": "json-server --watch db.json"
},
"author": "",
"license": "ISC",
"dependencies": {
"json-server": "^0.14.2"
}
}
预计到本地主机上启动服务器:3000
谢谢你的帮助!
回答如下:我认为这个问题是你归并与开始json-server的NPM运行脚本的想法,并没有完全实现,也方面。下面是我想尝试的步骤,假设你希望有一个运行脚本来启动你的JSON-服务器:
- 重命名
db.json
到package.json
,因为这实际上是对您的节点项目中的package.json
文件。你可能当您运行npm init
创建该文件。此文件是不是当你启动服务器与您的自定义脚本命令,你嘲笑的JSON-服务器JSON数据。 - 创建一个新的文件名为db.json并给它你想使用你的JSON-服务器嘲笑的JSON。例如,从文档:
db.json:
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
- 现在改变您的自定义运行脚本命令不包含特殊字符。例如,你的package.json内改变如下:
"scripts": { "json:server": "json-server --watch db.json" },
至:
"scripts": {
"start": "json-server --watch db.json"
},
- 现在开始您的自定义脚本命令服务器:
npm run start
。在这一点上不应该有启动服务器的任何错误。 - 现在,如果你去http://localhost:3000/posts/1,你应该得到以下JSON响应:
{ "id": 1, "title": "json-server", "author": "typicode" }
如何解决“NPM ERR!在NPM退出状态64“错误
我设立本地服务器,我正在我的服务器npm run json:server
但我收到以下错误:
NPM ERR!未能在[email protected] JSON:服务器脚本 'JSON-服务器--watch db.json'。
无法弄清楚如何解决这一问题?
我尝试更新npm update -g
,并没有帮助。也试过npm i -g npm
和安装JSON服务器在本地使用npm i --save-dev json-server
没有帮助
Lenovo-ideapad-990-95IKB:~/Desktop/jsonserver$ **npm run json:server**
> [email protected] json:server /home/zack/Desktop/jsonserver
> **json-server --watch db.json**
Could not find an option or flag "-c".
Usage: pub <command> [arguments]
Global options:
-h, --help Print this usage information.
--version Print pub version.
--[no-]trace Print debugging information when an error occurs.
--verbosity Control output verbosity.
[all] Show all output including internal tracing messages.
[error] Show only errors.
[io] Also show IO operations.
[normal] Show errors, warnings, and user messages.
[solver] Show steps during version resolution.
[warning] Show only errors and warnings.
-v, --verbose Shortcut for "--verbosity=all".
Available commands:
cache Work with the system cache.
deps Print package dependencies.
downgrade Downgrade the current package's dependencies to oldest versions.
get Get the current package's dependencies.
global Work with global packages.
help Display help information for pub.
publish Publish the current package to pub.dartlang.
run Run an executable from a package.
upgrade Upgrade the current package's dependencies to latest versions.
uploader Manage uploaders for a package on pub.dartlang.
version Print pub version.
Run "pub help <command>" for more information about a command.
See for detailed documentation.
npm ERR! Linux 4.19.5-041905-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "json:server"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! [email protected] json:server: `json-server --watch db.json`
npm ERR! **Exit status 64**
npm ERR!
npm ERR! **Failed at the [email protected] json:server script 'json-server --watch db.json'.**
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the jsonserver package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! json-server --watch db.json
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs jsonserver
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls jsonserver
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/zack/Desktop/jsonserver/npm-debug.log```
这里的package.json:
{
"name": "jsonserver",
"version": "1.0.0",
"description": "REST API Tracker",
"main": "index.js",
"scripts": {
"json:server": "json-server --watch db.json"
},
"author": "",
"license": "ISC",
"dependencies": {
"json-server": "^0.14.2"
}
}
预计到本地主机上启动服务器:3000
谢谢你的帮助!
回答如下:我认为这个问题是你归并与开始json-server的NPM运行脚本的想法,并没有完全实现,也方面。下面是我想尝试的步骤,假设你希望有一个运行脚本来启动你的JSON-服务器:
- 重命名
db.json
到package.json
,因为这实际上是对您的节点项目中的package.json
文件。你可能当您运行npm init
创建该文件。此文件是不是当你启动服务器与您的自定义脚本命令,你嘲笑的JSON-服务器JSON数据。 - 创建一个新的文件名为db.json并给它你想使用你的JSON-服务器嘲笑的JSON。例如,从文档:
db.json:
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
],
"profile": { "name": "typicode" }
}
- 现在改变您的自定义运行脚本命令不包含特殊字符。例如,你的package.json内改变如下:
"scripts": { "json:server": "json-server --watch db.json" },
至:
"scripts": {
"start": "json-server --watch db.json"
},
- 现在开始您的自定义脚本命令服务器:
npm run start
。在这一点上不应该有启动服务器的任何错误。 - 现在,如果你去http://localhost:3000/posts/1,你应该得到以下JSON响应:
{ "id": 1, "title": "json-server", "author": "typicode" }