{"id":20159,"library":"js-yaml-loader","title":"js-yaml-loader","description":"A Webpack loader that transpiles YAML files into JavaScript objects using js-yaml. Version 1.2.2 (latest) is stable with no active development since 2019. Unlike yaml-loader which outputs JSON, this loader supports YAML types disallowed in JSON (e.g., Infinity, RegExp, Function) via js-yaml's load. Options include safe load (default true) and iterator for multi-document YAML. Compatible with Webpack 4+.","status":"maintenance","version":"1.2.2","language":"javascript","source_language":"en","source_url":"https://github.com/wwilsman/js-yaml-loader","tags":["javascript","yaml","webpack","loader"],"install":[{"cmd":"npm install js-yaml-loader","lang":"bash","label":"npm"},{"cmd":"yarn add js-yaml-loader","lang":"bash","label":"yarn"},{"cmd":"pnpm add js-yaml-loader","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Peerdependency for YAML parsing","package":"js-yaml","optional":true}],"imports":[{"note":"Inline loader syntax with import is the expected usage.","wrong":"require('js-yaml-loader!./file.yml')","symbol":"default (loader)","correct":"import doc from 'js-yaml-loader!./file.yml'"},{"note":"Use 'use' and 'rules' in Webpack 4+. 'loaders' is deprecated.","wrong":"module.exports = { module: { loaders: [{ test: /\\.yaml$/, loader: 'js-yaml-loader' }] } }","symbol":"config rule","correct":"module.exports = { module: { rules: [{ test: /\\.yaml$/, use: 'js-yaml-loader' }] } }"},{"note":"Pass options as object in Webpack 4+; query string syntax works but is less flexible.","wrong":"module.exports = { module: { rules: [{ test: /\\.yaml$/, loader: 'js-yaml-loader?safe=false' }] } }","symbol":"options","correct":"module.exports = { module: { rules: [{ test: /\\.yaml$/, use: { loader: 'js-yaml-loader', options: { safe: false } } }] } }"}],"quickstart":{"code":"// webpack.config.js\nmodule.exports = {\n  module: {\n    rules: [\n      {\n        test: /\\.(yaml|yml)$/,\n        use: [\n          {\n            loader: 'js-yaml-loader',\n            options: { safe: true } // default, prevents unsafe types\n          }\n        ]\n      }\n    ]\n  }\n};\n\n// In your source file:\nimport config from './config.yaml';\nconsole.log(config.database.host);","lang":"javascript","description":"Configures Webpack to import YAML files as JavaScript objects with safe loading by default."},"warnings":[{"fix":"Add option { safe: false } to loader configuration or inline query: js-yaml-loader?safe=false","message":"safeLoad is used by default, which disables unsafe YAML types (RegExp, Function, undefined). Set safe: false to allow them.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use yaml-loader if JSON output is needed.","message":"This loader outputs JavaScript objects, not JSON. If you expect a JSON string, use yaml-loader instead.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Test with Webpack 5 or migrate to yaml-loader or custom loader.","message":"The package is in maintenance mode; no updates since 2019. Consider alternatives for Webpack 5+ compatibility.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-25T00:00:00.000Z","next_check":"2026-07-24T00:00:00.000Z","problems":[{"fix":"Add a rule for .yaml files using js-yaml-loader: { test: /\\.yaml$/, use: 'js-yaml-loader' }","cause":"Webpack cannot parse YAML files because the loader rule is missing or misconfigured.","error":"Module parse failed: Unexpected token (1:1)\nYou may need an appropriate loader to handle this file type."},{"fix":"Run: npm install js-yaml","cause":"js-yaml is a peer dependency and must be installed separately.","error":"Error: Cannot find module 'js-yaml'"},{"fix":"Ensure js-yaml version 3.x is installed (npm install js-yaml@3)","cause":"The js-yaml package version is too old or incompatible; safeLoad was renamed in js-yaml v4.","error":"TypeError: (0 , _jsYaml.safeLoad) is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}