'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?
Solution 1:[1]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | miensol |
