angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

'Path must be a string. Received undefined' after upgrading to 2.3.1

Open ppopadiyn opened this issue 9 years ago • 3 comments

OS?

Ubuntu 16.04

Versions.

angular-cli: 1.0.0-beta.24 node: 6.9.2 npm: 3.10.9

Repro steps.

I tried to upgrade my project from 2.2.3 to 2.3.1 and angular-cli from beta.22-1 to beta.24, and started getting this error on build. I practically copy/pasted all dependencies generated by the ng new command. This is my package.json:

{
  "dependencies": {
    "body-parser": "^1.15.2",
    "compression": "^1.6.2",
    "express": "^4.14.0",
    "helmet": "^3.1.0",
    "morgan": "^1.7.0"
  },
  "devDependencies": {
    "concurrently": "^3.1.0",
    "nodemon": "^1.11.0",
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2",
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.24",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.0.2",
    "typescript": "~2.0.3"
  }
}

And my angular-cli.json is:

{
  "project": {
    "version": "1.0.0-beta.22-1",
    "name": "my-project-name"
  },
  "apps": [
    {
      "root": "client",
      "outDir": "dist",
      "assets": [
        "assets"
      ],
      "index": "index.html",
      "main": "main.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "my-project-name",
      "mobile": false,
      "styles": [
        "styles.less",
        "assets/icons/icons.css"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "addons": [],
  "packages": [],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "less",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    }
  }
}

The log given by the failure.

Path must be a string. Received undefined TypeError: Path must be a string. Received undefined at assertPath (path.js:7:11) at Object.join (path.js:1211:7) at Object.exports.getWebpackNonAotConfigPartial (/home/myuser/work/myproject/src/node_modules/angular-cli/models/webpack-build-typescript.js:24:26) at new NgCliWebpackConfig (/home/myuser/work/myproject/src/node_modules/angular-cli/models/webpack-config.js:26:42) at Class.run (/home/myuser/work/myproject/src/node_modules/angular-cli/tasks/build-webpack.js:18:22) at Class.run (/home/myuser/work/myproject/src/node_modules/angular-cli/commands/build.js:60:26) at Class. (/home/myuser/work/myproject/src/node_modules/angular-cli/ember-cli/lib/models/command.js:152:17) at process._tickCallback (internal/process/next_tick.js:103:7)

Thanks! We'll be in touch soon.

ppopadiyn avatar Dec 28 '16 10:12 ppopadiyn

You say you copied the bits from ng new, but that's not the right step! You need to perform ng init in the root of the project. The CLI will interactively ask about overwriting files. Enter d for Difference on any files you may want to keep changes you've made, then either enter n to decline the overwrite, and apply the changes yourself. Overwrite those which have no changes or don't need changes saved with y.

Also, be sure to upgrade your local CLI installation in addition to the global installation.

You can see for yourself that the CLI in your project isn't properly upgraded: "version": "1.0.0-beta.22-1"

celliott181 avatar Dec 28 '16 16:12 celliott181

Yes, that did the trick. Thanks.

ppopadiyn avatar Dec 29 '16 16:12 ppopadiyn

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.