简体   繁体   English

出现错误:找不到模块“js-yaml”

[英]Getting Error: Cannot find module 'js-yaml'

I have installed js-yaml with this command我已经用这个命令安装了js-yaml

npm i @types/js-yaml

And my package.json looks like this我的package.json看起来像这样

"dependencies": {
  "@types/js-yaml": "^4.0.5",
  "aws-cdk-lib": "2.20.0",
  "constructs": "^10.0.0",
  "source-map-support": "^0.5.16",
  "ts-sync-request": "^1.4.1"
}

And my code doesn't show any error in vscode而且我的代码在vscode中没有显示任何错误

import * as yml from 'js-yaml';
...
const metricsServerManifestUrl = 'https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml';
const manifest = yml.loadAll(new SyncRequestClient().get(metricsServerManifestUrl));
cluster.addManifest('metrics-server', manifest);

But I'm getting this error when I try to run application但是当我尝试运行应用程序时出现此错误

Error: Cannot find module 'js-yaml'错误:找不到模块“js-yaml”

How can I fix this?我怎样才能解决这个问题?

The @types/js-yaml contains only type definitions used by TypeScript compiler to verify your code. @types/js-yaml仅包含 TypeScript 编译器用于验证您的代码的类型定义。 However, it doesn't contain the actual implementation required at runtime.但是,它不包含运行时所需的实际实现。

You should install npm install js-yaml --save .您应该安装npm install js-yaml --save

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

相关问题 Vue3.js )错误:找不到模块'firebase' - Vue3.js ) Error: Cannot find module 'firebase' 在服务器上出现“找不到模块”错误,但本地有效 - Getting error 'Cannot find module' on server but local works 错误:在谷歌应用引擎上部署 node.js 后找不到模块“/workspace/server.js” - Error: Cannot find module '/workspace/server.js' upon node js deploy on google app engine 找不到模块'axios' - Cannot find module 'axios' 错误:找不到模块“@aws-sdk/client-sns” - Error: Cannot find module '@aws-sdk/client-sns' 找不到模块'puppeteer' - Cannot find module 'puppeteer' 错误:找不到模块“aws-api-gateway-client” - Error: Cannot find module 'aws-api-gateway-client' 初始化“@nuxtjs/firebase”模块时出现 Nuxt 致命错误 - 找不到模块“firebase/compat/app” - Nuxt FATAL error when initializing '@nuxtjs/firebase' module - Cannot find module 'firebase/compat/app' FIrebase 部署错误:找不到模块“firebase-admin” - FIrebase deploy error: Cannot find module 'firebase-admin' 带有 AWS Lambda 错误“找不到模块”的无服务器框架 - Serverless Framework with AWS Lambda error "Cannot find module"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM