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

ng fails on Version.assertPostWebpackVersion() on 1.0.0-beta.14

Open andrevmatos opened this issue 10 years ago • 32 comments

  1. OS? Arch Linux with latest kernel and Node 6.5.0 through NVM
  2. Versions: angular-cli: 1.0.0-beta.14 node: 6.5.0 os: linux x64
  3. Repro steps. Local installation, empty folder: npm i angular-cli ./node_modules/.bin/ng init # fails
  4. The log given by the failure. fs.js:640 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^

TypeError: path must be a string or Buffer at TypeError (native) at Object.fs.openSync (fs.js:640:18) at Object.fs.readFileSync (fs.js:508:33) at Function.Version.fromProject (/sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/angular-cli/upgrade/version.js:87:31) at Function.Version.isPreWebpack (/sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/angular-cli/upgrade/version.js:111:31) at Function.Version.assertPostWebpackVersion (/sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/angular-cli/upgrade/version.js:97:18) at /sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/angular-cli/bin/ng:25:15 at /sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/resolve/lib/async.js:44:21 at ondir (/sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/resolve/lib/async.js:187:31) at /sec/Dev/Link/scripts/web_files_py/flask_ged/ng/node_modules/resolve/lib/async.js:153:3

  1. Mention any other details that might be useful. Commenting out the line 25 on angular-cli/bin/ng makes everything work again. This with the check Version.assertPostWebpackVersion(), was added on commit 21003b1dc359e5d32e493911ceb5b72966d4c0ad .

andrevmatos avatar Sep 15 '16 14:09 andrevmatos

Same with both Windows 7 and Windows 8.1 node version : 6.5 npm version : 3.10.3

Steps :

npm install -g angular-cli@latest go in work directory npm install angular-cli@latest ng new

BenoitFroment avatar Sep 15 '16 16:09 BenoitFroment

same on macOS

sterlingfs avatar Sep 15 '16 17:09 sterlingfs

same here on Mac OS sierra with node 6.5.0

alexverdaguer avatar Sep 15 '16 21:09 alexverdaguer

same on Linux Mint with node 6.5

iuliust avatar Sep 16 '16 01:09 iuliust

Same here on Mac OSX Yosemite and Windows 10 with node 6.5.0.

Mattee avatar Sep 16 '16 07:09 Mattee

any news or trick about this?

BenoitFroment avatar Sep 16 '16 07:09 BenoitFroment

Same on OS X El Capitan node v6.6.0 npm 3.10.7

Installed latest version (*-beta.14) tried ng --help same error:

ng --help fs.js:640 return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode); ^

TypeError: path must be a string or Buffer at TypeError (native) at Object.fs.openSync (fs.js:640:18) at Object.fs.readFileSync (fs.js:508:33) at Function.Version.fromProject (/usr/local/lib/node_modules/angular-cli/upgrade/version.js:87:31) at Function.Version.isPreWebpack (/usr/local/lib/node_modules/angular-cli/upgrade/version.js:111:31) at Function.Version.assertPostWebpackVersion (/usr/local/lib/node_modules/angular-cli/upgrade/version.js:97:18) at /usr/local/lib/node_modules/angular-cli/bin/ng:25:15 at /usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:44:21 at ondir (/usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:187:31) at /usr/local/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:153:39

hopefullToo avatar Sep 16 '16 14:09 hopefullToo

@Aorewen Simplest workaround to continue working in your project is comment line 25 of node_modules/angular-cli/bin/ng : // Version.assertPostWebpackVersion(); Until it is fixed properly.

andrevmatos avatar Sep 16 '16 14:09 andrevmatos

I just commented out line 25 on angular-cli/bin/ng . but now ng hangs if I call ng --help a new line is displayed and I can enter any text but n nothing happens. I quit the call with ^C.

I do not know if this has to do anything with this nam error message I got after installing angular-cli:

peer dep missing: [email protected] || 2.x.x, required by [email protected]

In the meanwhile I installed web pack: npm ls webpack -g /usr/local/lib └── [email protected]

But I still get this error: npm ls angular-cli [email protected] /usr/local/lib/node_modules/angular-cli └── UNMET PEER DEPENDENCY [email protected]

Installed web [email protected] but now I get the "old" message: npm ls angular-cli .... npm ERR! peer dep missing: [email protected] || 2.x.x, required by [email protected]

hopefullToo avatar Sep 16 '16 14:09 hopefullToo

Updated node to v6.6.0 and now it works !

alexverdaguer avatar Sep 16 '16 17:09 alexverdaguer

I fix this for node 6.5.0 with #2178

ValeryVS avatar Sep 16 '16 18:09 ValeryVS

Persisted in v6.6.0 for me

➜  angular nvm exec 6.6.0 ng 
Running node v6.6.0 (npm v3.10.7)
fs.js:640
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

TypeError: path must be a string or Buffer
    at TypeError (native)
    at Object.fs.openSync (fs.js:640:18)
    at Object.fs.readFileSync (fs.js:508:33)
    at Function.Version.fromProject (/home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/upgrade/version.js:87:31)
    at Function.Version.isPreWebpack (/home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/upgrade/version.js:111:31)
    at Function.Version.assertPostWebpackVersion (/home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/upgrade/version.js:97:18)
    at /home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/bin/ng:25:15
    at /home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:44:21
    at ondir (/home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:187:31)
    at /home/jelf/.nvm/versions/node/v6.6.0/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:153:39

OS gentoo linux, [email protected]

JelF avatar Sep 20 '16 07:09 JelF

Same issue for me on node 6.6.0, windows 10, I just get the upgrade warning and I'm asking for the latest version of angular-cli, I've done about 5 re-install cycles now.

mikedsharp avatar Sep 20 '16 19:09 mikedsharp

I'm on a linux machine and this happens in one directory but not in another. Weird.

Edit: The directory that worked was an existing project. The one that didn't work was an empty project (ng init hadn't been ran). I didn't some investigation and it's looking for the angular-cli.json file. That file doesn't exist until you run "ng init". This seems like a bug. It's impossible to create new projects.

I'm not sure how this would ever work for new projects. The ng bin script checks looks for an angular-cli.json first thing and blows up when it doesn't find it.

caseyhoward avatar Sep 21 '16 03:09 caseyhoward

Upon further review, I think I see the error:

https://github.com/angular/angular-cli/blob/master/packages/angular-cli/upgrade/version.ts#L79

That line should either check if the file exists or be moved into the try block below (line 82). It's trying to read in angular-cli.json. I'm not sure that's the best fix, but I changed it locally and it works.

caseyhoward avatar Sep 21 '16 03:09 caseyhoward

@caseyhoward can you make a diff?

nevermind, solved by touch angular-cli.json

JelF avatar Sep 21 '16 07:09 JelF

@caseyhoward No need for more try..catch There is fix, wait for merging #2178 https://github.com/angular/angular-cli/pull/2178/files

Workaround: create blank angular-cli.json

ValeryVS avatar Sep 21 '16 19:09 ValeryVS

@hansl can you have a look?

filipesilva avatar Sep 22 '16 02:09 filipesilva

+1

error on node 6.6.0, npm 3.10.3, osx 10.10.5

davemo88 avatar Sep 22 '16 20:09 davemo88

+1

[imho] this should work:

$ mkdir noglobal $ cd noglobal $ npm init -f $ npm i -D angular-cli@latest $ ./node_modules/.bin/ng init

nlovett avatar Sep 25 '16 14:09 nlovett