简体   繁体   English

NPM 无法安装软件包,引用缺少 package.json

[英]NPM cannot install packages, cites missing package.json

I'm doing the AWS beginner course and one of the main steps is to install the CDK toolkit for AWS-CLI, and the only given method to do so is by using NPM. I'm not a dev, and totally new to this side of computing, but I used a tutorial and downloaded node.js along with npm, and copy pasted:我正在学习 AWS 初学者课程,主要步骤之一是为 AWS-CLI 安装 CDK 工具包,唯一给出的方法是使用 NPM。我不是开发人员,对此完全陌生计算方面,但我使用了教程并下载了 node.js 和 npm,然后复制粘贴:

npm install -g aws-cdk

It gives me this error each and every time:它每次都给我这个错误:

    Error: Cannot find module '../package.json'
Require stack:
- C:\Users\darth\AppData\Roaming\npm\node_modules\npm\lib\cli.js
- C:\Users\darth\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js
←[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:778:27)←[39m
←[90m    at Module.require (node:internal/modules/cjs/loader:1005:19)←[39m
←[90m    at require (node:internal/modules/cjs/helpers:102:18)←[39m
    at module.exports (C:\Users\darth\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\lib\cli.js:15:21)
    at Object.<anonymous> (C:\Users\darth\AppData\Roaming\npm\node_modules\←[4mnpm←[24m\bin\npm-cli.js:2:25)
←[90m    at Module._compile (node:internal/modules/cjs/loader:1103:14)←[39m
←[90m    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)←[39m
←[90m    at Module.load (node:internal/modules/cjs/loader:981:32)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:822:12)←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: [
    ←[32m'C:\\Users\\darth\\AppData\\Roaming\\npm\\node_modules\\npm\\lib\\cli.js'←[39m,
    ←[32m'C:\\Users\\darth\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js'←[39m
  ]
}

I've tried reinstalling the node.js, I've tried npm init, I created package.json files for both default and aws-cdk files, and even repairing NPM, to no avail.我试过重新安装 node.js,我试过 npm init,我为默认文件和 aws-cdk 文件创建了 package.json 文件,甚至修复了 NPM,但都无济于事。 Does anyone have any insight into this?有没有人对此有任何见解? Thank you!谢谢!

If you have node and npm installed.如果您安装了节点和 npm。

You need to create a folder.您需要创建一个文件夹。 This folder will be your project.该文件夹将是您的项目。 Let's assume you created a folder called myProject.假设您创建了一个名为 myProject 的文件夹。

This can be achieved in the command line by running this command:这可以通过运行以下命令在命令行中实现:

mkdir myProject

In a terminal, you need to navigate to that folder在终端中,您需要导航到该文件夹

cd /path/to/your/folder 

Run this command to generate a package.json file.运行此命令生成一个 package.json 文件。

npm init

From the root of your project.从你的项目的根。 This will generate a package.json file.这将生成一个 package.json 文件。

Feel free to use the default values.随意使用默认值。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 云构建 angular npm 运行抛出 package.json 错误 - Cloud build angular npm run throws package.json error AWS CDK 代码管道开发——NodejsFunction Package.json 依赖项如何安装? - AWS CDK Code Pipeline Development - How Do I Install NodejsFunction Package.json Dependencies? 作为一个组织,你如何发布和安装私有的 npm package 到 GitHub 包? - How do you publish and install a private npm package to GitHub packages as an organisation? Google Cloud Functions 错误:“找不到模块‘sharp’”,但它在我的 package.json 中 - Google Cloud Functions error: "Cannot find module 'sharp'" but it's in my package.json 如何在 BigQuery 中安装 npm 包? - How to install npm packages in BigQuery? NodeJS Elastic Beanstalk 环境报错 Cannot find module 'node-linux-arm64/package.json' - NodeJS Elastic Beanstalk environment error Cannot find module 'node-linux-arm64/package.json' package.json 在 Azure 上的 web 应用程序中找不到文件 - package.json file not found in web application on Azure 如何在 GitLab CI/CD 上碰撞 package.json 版本的项目? - How to bump package.json version of project on GitLab CI/CD? Firebase CLI 部署错误:读取函数/包时出错。json - Firebase CLI deploy Error: There was an error reading functions/package.json 如何在 dialogflow 内联实现 package.json 中使用节点引擎版本 10 进行设置? - How to set using node engine version 10 in dialogflow inline fulfilment package.json?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM