[英]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.