Storybook: Module build failed (from ./node_modules/ts-loader/index.js): TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined

Created on 21 Oct 2019  路  7Comments  路  Source: storybookjs/storybook

storybook throwing error after upgrading from 5.1.9 to 5.2.4

Package JSON

  "dependencies": {
    "@angular/animations": "^8.2.11",
    "@angular/cdk": "^7.2.1",
    "@angular/common": "^8.2.11",
    "@angular/compiler": "^8.2.11",
    "@angular/core": "^8.2.11",
    "@angular/forms": "^8.2.11",
    "@angular/http": "^7.2.15",
    "@angular/platform-browser": "^8.2.11",
    "@angular/platform-browser-dynamic": "^8.2.11",
    "@angular/router": "^8.2.11",
    "core-js": "^2.6.1",
    "gulp": "^4.0.0",
    "rxjs": "^6.5.3",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.12",
    "@angular-devkit/build-ng-packagr": "^0.803.12",
    "@angular/cli": "^8.3.12",
    "@angular/compiler-cli": "^8.2.11",
    "@angular/language-service": "^8.2.11",
    "@angular/material": "^7.2.1",
    "@babel/core": "^7.2.2",
    "@storybook/addon-actions": "^5.2.4",
    "@storybook/addon-knobs": "^5.2.4",
    "@storybook/addon-links": "^5.2.4",
    "@storybook/addon-notes": "^5.2.4",
    "@storybook/addon-options": "^5.2.4",
    "@storybook/addon-viewport": "^5.2.4",
    "@storybook/addons": "^5.2.4",
    "@storybook/angular": "^5.2.4",
    "@storybook/storybook-deployer": "^2.8.1",
    "@types/jasmine": "^3.3.5",
    "@types/jasminewd2": "^2.0.6",
    "@types/node": "^10.12.18",
    "babel-loader": "^8.0.6",
    "codelyzer": "^4.4.4",
    "jasmine-core": "^3.3.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "^3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "^2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "karma-junit-reporter": "^1.2.0",
    "ng-packagr": "^5.7.0",
    "ngx-perfect-scrollbar": "^7.1.0",
    "node-sass": "^4.11.0",
    "prettier": "^1.15.3",
    "protractor": "^5.4.2",
    "puppeteer": "^1.20.0",
    "rimraf": "^2.6.3",
    "scss-bundle": "^2.3.2",
    "ts-node": "~7.0.0",
    "tsickle": "^0.37.0",
    "tslib": "^1.10.0",
    "tslint": "^5.12.0",
    "tslint-config-prettier": "^1.17.0",
    "typescript": "~3.5.3"
  }

error

core help wanted question / support typescript

Most helpful comment

馃 everything is working fine for me with "@angular-devkit/build-angular": "0.803.12".

@garvit-rajput, do you have a tsconfig.json in your storybook config folder (usually .storybook/)? It should look like:

{
  "extends": "../tsconfig.json",
  "exclude": [
    "../src/test.ts",
    "../src/**/*.spec.ts",
    "../projects/**/*.spec.ts"
  ],
  "include": [
    "../src/**/*",
    "../projects/**/*"
  ]
}

All 7 comments

@garvit-rajput can you share your angular.json and tsconfig.json files, and the command you are using to start your StoryBook too? It looks like StoryBook does not find any tsconfig.json file to use to compile TS files.

TS Config

{
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "es2015",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es5",
    "typeRoots": ["node_modules/@types","./typings.d.ts"],
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "lib": [
      "es2017",
      "dom"
    ],
    "paths": {
      "ui": ["dist/ui"],
      "ui/*": ["dist/ui/*"]
    }
  }
}

angular.json

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ui-components": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/ui-components",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "src/styles.scss"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "ui-components:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "ui-components:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "ui-components:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.scss"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "ui-components-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "ui-components:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "ui-components:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "ui": {
      "root": "projects/ui",
      "sourceRoot": "projects/ui/src",
      "projectType": "library",
      "prefix": "once",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-ng-packagr:build",
          "options": {
            "tsConfig": "projects/ui/tsconfig.lib.json",
            "project": "projects/ui/ng-package.json"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "projects/ui/src/test.ts",
            "tsConfig": "projects/ui/tsconfig.spec.json",
            "karmaConfig": "projects/ui/karma.conf.js"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "projects/ui/tsconfig.lib.json",
              "projects/ui/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "ui-components"
}

Command to start start-storybook

Same here :-(

Screenshot 2019-10-30 at 11 36 06

Hi @garvit-rajput I found out that if you use: "@angular-devkit/build-angular": "~0.802.0" the problem is solved. Anyway, I think the Storybook team should be able to make it work with the latest version from @angular-devkit/build-angular.

馃 everything is working fine for me with "@angular-devkit/build-angular": "0.803.12".

@garvit-rajput, do you have a tsconfig.json in your storybook config folder (usually .storybook/)? It should look like:

{
  "extends": "../tsconfig.json",
  "exclude": [
    "../src/test.ts",
    "../src/**/*.spec.ts",
    "../projects/**/*.spec.ts"
  ],
  "include": [
    "../src/**/*",
    "../projects/**/*"
  ]
}

@gaetanmaisse Thanks!
that worked for me :)

馃 everything is working fine for me with "@angular-devkit/build-angular": "0.803.12".

@garvit-rajput, do you have a tsconfig.json in your storybook config folder (usually .storybook/)? It should look like:

{
  "extends": "../tsconfig.json",
  "exclude": [
    "../src/test.ts",
    "../src/**/*.spec.ts",
    "../projects/**/*.spec.ts"
  ],
  "include": [
    "../src/**/*",
    "../projects/**/*"
  ]
}

worked for me after making a new file tsconfig.json with above content in .storybook config folder and also updated @angular-devkit/build-angular": "0.803.12"

Was this page helpful?
0 / 5 - 0 ratings