jquery - 如何为 jquery 构建 package.json
问题描述
我是 Typescript 的新手,我想安装jquery.d.ts
以便可以在我的 .ts 文件中使用 jQuery。为了获得 jquery.d.ts,我安装了 npm,然后发出命令npm install jquery
。这导致了以下错误:
npm WARN saveError ENOENT:没有这样的文件或目录,打开 'C:\Users\darli\package.json'
我也尝试发出以下命令,但得到相同的结果:
npm install --save @types/jquery
搜索解决方案后,我现在明白我需要 package.json 文件来告诉 npm 安装什么。我尝试运行npm init
,这导致 npm 向我询问有关我要安装的软件包的问题。我在 GitHub 上找到了实际文件,但它要求我在另一个名为 index.js 的文件中为其提供入口点,我不知道如何回答这个问题。
谁能帮我创建 package.json 文件或将我指向解释如何执行此操作的资源?在我看来,这个 package.json 文件应该很容易放在一起,因为 jquery 非常流行,但我似乎无法掌握它。
解决方案
You'll need to run the command npm init
then you can install the jQuery package as you need.
Once you've ran npm init
you will see a new file in your directory labeled package.json - this is the file that saves various information about your NPM related data. You should then be able to run your command npm install --save @types/jquery
without any errors.
For more information on this process, checkout https://docs.npmjs.com/cli/init
推荐阅读
- c++ - 根据非类型参数值推导出类型列表
- angular - 导航子路由Angular
- python - 有没有办法使用 Google Directory API 监视方法来监视特定用户或属性
- android - 应用程序关闭时无法在 Job Service 中访问 Internet
- c# - .NET Core 3.1 WebBrowserControl 导航后读取html
- scala - 使用 Databricks 终止结构化流队列
- javascript - 如何在javascript中将数组对象更改为嵌套对象
- highcharts - Highchart:日期时间 X 轴标签未正确显示
- python - 如何使用 Python 3 在 Pycharm 中安装 PIL?
- prestashop - 在 Prestashop 1.7 上手动更新模块