Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何创建package.json文件?_Json_Node.js_Npm_Npm Install - Fatal编程技术网

如何创建package.json文件?

如何创建package.json文件?,json,node.js,npm,npm-install,Json,Node.js,Npm,Npm Install,警告:在未经许可的水域内,无障碍物涉水。来吧。在Mac终端中: package.json This is most likely not a problem with npm itself. npm ERR! package.json npm can't find a package.json file in your current directory. Please include the following file with any support request: npm ERR!

警告:在未经许可的水域内,无障碍物涉水。来吧。在Mac终端中:

package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

Please include the following file with any support request:
npm ERR!     /Users/stickupartist/portfolio/npm-debug.log
stickup-artists-macbook-pro:portfolio stickupartist$ npm init
This utility will walk you through creating a package.json file.
所指的是什么效用

接下来:

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Name: (portfolio)
我的名字有什么不对吗?我正在用Meteor和MacOSX在我的本地机器上工作


谢谢大家!

要创建
package.json
,您可以运行(并查看其选项)或手动创建基于的文件

下面是一个简单的
包。json

{
  "name": "my-cool-app",
  "version": "1.0.0",
  "description": "This is my cool app",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
  },
  "author": "Me",
  "license": "MIT",
  "dependencies": {
    "jquery": "1.1.1",
  }
}
现在,就错误而言:

抱歉,名称只能包含URL友好字符

这意味着包名不符合以下条件之一,主要是:

包名称不得包含任何非url安全字符(因为名称最终是url的一部分)

这很可能是因为您将包名包装在
中。
的意思是值的占位符。在实际输入时,您应该使用适当的值覆盖它(以及它包装的任何内容),在本例中是一个有效的包名

这是定义
npm install
命令的方式,而不是使用它:

定义:

npm install <package_name_goes_here>

请参阅nem035创建package.json的答案(只需
npm init


对于您的另一个问题:在
npm安装中--save
指的是包的名称。您可以安装包的名称,而不需要括号。例如,
npm安装公文包--save

尝试使用npm init-y它将起作用

使用:
npm init-y

然后安装你的软件包


当我在注销会话时遇到同样的问题时,这对我很有效。然后重新登录并尝试npm安装-y。这对我来说很有效。

感谢您的回复nem:我尝试了“npm init”,得到了“name:(公文包)npm WARN init cancelled”。然后“使用
npm install--save
安装包并将其保存为package.json文件中的依赖项”。随时按^C退出。姓名:(公文包)我愿意尝试手动操作。我应该将package.json保存到哪里?非常感谢。你最好多了解一下它本身。他们的文件将解释一切。您需要在项目的根目录(顶部)中创建
package.json
。感谢链接。感谢定义!我运行了它,它在根目录中安装了package.json。谢谢
{
  "name": "my-cool-app",
  "version": "1.0.0",
  "description": "This is my cool app",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
  },
  "author": "Me",
  "license": "MIT",
  "dependencies": {
    "jquery": "1.1.1",
  }
}
npm install <package_name_goes_here>
npm install portfolio