问题
When I am trying to create new project by using the command, ng new project-name, I am getting error like below:
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/lib/node_modules/angular-cli/upgrade/version.js:87:31) at Function.Version.isPreWebpack (/usr/lib/node_modules/angular-cli/upgrade/version.js:111:31) at Function.Version.assertPostWebpackVersion (/usr/lib/node_modules/angular-cli/upgrade/version.js:97:18) at /usr/lib/node_modules/angular-cli/bin/ng:25:15 at /usr/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:44:21 at ondir (/usr/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:187:31) at /usr/lib/node_modules/angular-cli/node_modules/resolve/lib/async.js:153:39
- ubuntu 14.04 64-bit
- node 6.6.0
- npm 3.9.5
- angular-cli@1.0.0-beta.14
I suspect some issues while installing angular-cli but I am not sure. Any help would be helpful.
回答1:
Had the same issue was able to fix it by doing the below:
npm uninstall -g angular-cli
npm cache clean
npm install -g node-gyp
npm install -g angular-cli
Then do ng --version to see if installed successfully.
回答2:
I was having the same issue, and this post was helpful: https://github.com/angular/angular-cli/issues/2135
It's maybe a little too hacky to really recommend as a solution, but this answer at least got me going:
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.
回答3:
Please try npm install -g webpack
before npm install -g angular-cli
来源:https://stackoverflow.com/questions/39541930/error-while-creating-new-project-with-angular-cli