node.js - "not listed in package.json", 安装 NTVS 时的 node.js

标签 node.js express dependencies npm

enter image description here

在模块状态显示后的红色框中..任何人都可以帮助我..提前致谢

最佳答案

打开命令提示符并 cd 进入项目目录(您可以在解决方案资源管理器中右键单击项目并选择 Open command prompt from here...)。

键入 npm init 并在出现提示时填写字段(或按 Enter 以采用默认值)。输出应该看起来像这样......

C:\Anthony\Demo\ExpressApp1\ExpressApp1>npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sane defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

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

Press ^C at any time to quit.
name: (ExpressApp1)
version: (0.0.0)
description:
entry point: (app.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to C:\Anthony\Demo\ExpressApp1\ExpressApp1\package.json:

{
  "name": "ExpressApp1",
  "version": "0.0.0",
  "description": "",
  "main": "app.js",
  "dependencies": {
    "express": "~3.4.4",
    "jade": "~1.1.5",
    "stylus": "~0.42.2"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this ok? (yes)

如果由于某种原因 npm init 不起作用,您可以将以下文本保存到项目根目录中名为 package.json 的文件中,并更新值以匹配项目中的包。

{
  "name": "ExpressApp1",
  "version": "0.0.0",
  "description": "",
  "main": "app.js",
  "dependencies": {
    "express": "~3.4.4",
    "jade": "~1.1.5",
    "stylus": "~0.42.2"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

第三个选项是删除项目中的 npm_modules 文件夹。然后您可以在解决方案资源管理器中右键单击 npm“文件夹”,选择 Manage npm modules...,然后重新安装包。以这种方式安装它们应该会为您创建一个 package.json

关于node.js - "not listed in package.json", 安装 NTVS 时的 node.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21595599/

相关文章:

javascript - 如何使用 Node 创建一个子进程作为特定用户?

javascript - 可以用node的Elasticsearch在不重写的情况下仅更新特定字段吗?

amazon-web-services - AWS Lambda 函数无法从 EC2 实例 : SequelizeConnectionError connect ETIMEDOUT 访问 MySQL 数据库

css - 如果指定了端口,样式表将不起作用 - node.js express

maven - 使用 Gradle 或 Maven 从 Nexus Repository 上传 Artifact 和下载依赖项

android - 使用 log4j 更新 Android Studio 后 gradle 构建出错

c++ - 以下是否表明设计不好?

node.js - 从 passportjs 中的刷新 token 获取 oauth 访问 token

python - 使用 Node js 快速服务器调用 python 脚本

node.js - Node.js 中的 "connect EMFILE"错误