简体   繁体   中英

Getting Error: Cannot find module 'js-yaml'

I have installed js-yaml with this command

npm i @types/js-yaml

And my package.json looks like this

"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

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'

How can I fix this?

The @types/js-yaml contains only type definitions used by TypeScript compiler to verify your code. However, it doesn't contain the actual implementation required at runtime.

You should install npm install js-yaml --save .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM