I am currently using Windows 10 on this device, same as my laptop which doesn't seem to be having issues with the cli. I also have npm version 3.10.6 and nodejs version 6.4.0. I am running the command prompt in Administrator mode if that's makes a difference.
Regrettably like stated in the title I cannot run any angular-cli commands without the error, including "--version", but I did install angular-cli@webpack with npm. I also haven't started creating an app yet on this device due to this error.
Log from command prompt: (same error on everything command)
$ ng --version
(node:11820) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
Error while running script "C:\Program Files\nodejs\node_modules\angular-cli\addon\ng2\commands\serve.ts":
Error: Cannot find module 'portfinder'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\angular-cli\addon\ng2\commands\serve.ts:6:18)
at Module._compile (module.js:556:32)
at Object.require.extensions..ts (C:\Program Files\nodejs\node_modules\angular-cli\lib\cli\index.js:29:14)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Class.module.exports.includedCommands (C:\Program Files\nodejs\node_modules\angular-cli\addon\ng2\index.js:16:16)
at C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:392:61
at Array.forEach (native)
at Project.addonCommands (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:391:15)
at Project.eachAddonCommand (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:426:30)
at module.exports (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
at CLI.<anonymous> (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\cli.js:34:26)
at lib$rsvp$$internal$$tryCatch (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
Cannot find module 'portfinder'
Error: Cannot find module 'portfinder'
at Function.Module._resolveFilename (module.js:455:15)
at Function.Module._load (module.js:403:25)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Program Files\nodejs\node_modules\angular-cli\addon\ng2\commands\serve.ts:6:18)
at Module._compile (module.js:556:32)
at Object.require.extensions..ts (C:\Program Files\nodejs\node_modules\angular-cli\lib\cli\index.js:29:14)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Class.module.exports.includedCommands (C:\Program Files\nodejs\node_modules\angular-cli\addon\ng2\index.js:16:16)
at C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:392:61
at Array.forEach (native)
at Project.addonCommands (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:391:15)
at Project.eachAddonCommand (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:426:30)
at module.exports (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
at CLI.<anonymous> (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\cli.js:34:26)
at lib$rsvp$$internal$$tryCatch (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
at lib$rsvp$$internal$$invokeCallback (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
at lib$rsvp$$internal$$publish (C:\Program Files\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
I have tried solutions from these: Angular2 : Need to create angular2 folder structure using latest angularCLI Webpack
and Error: Cannot find module 'portfinder' with Webpack release and NPM 2 #1770 with no success and cannot seem to find anything else about this on google. Unlike the latter link, I do not care what version of npm I am using.
I can't reproduce this on Windows 10 myself. It looks like your install is missing a package, which can be the result of a broken install or of a NPM upgrade without reinstall.
This should work if that's the case, but you say you've tried it already:
npm uninstall -g angular-cli
npm cache clean
npm install -g angular-cli@webpack
I'll leave the issue open in case there's a way to repro this I can use to debug.
Same Problem here.
uninstall and install not solveing this.
If i run any ng command outside a cli Project it works fine.
$ ng v
angular-cli: 1.0.0-beta.11-webpack.2
node: 4.4.0
os: win32 x64
History:
I build a app with cli yesterday. Everything works fine.
Then I moved my files into a Project to push all to git.
clone this Project and run:
npm i
npm install --save-dev angular-cli@webpack
this throws error:
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN optional Skipping failed optional dependency /karma/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN @angular/[email protected] requires a peer of typescript@^1.9.0-dev but none was installed.
npm WARN [email protected] requires a peer of typescript@^1.8.0 || ^1.9.0-dev but none was installed.
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\Program Files\nodejs\node.exe" "D:\Users\damu1de\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "--save-dev" "angular-cli@webpack"
npm ERR! node v4.4.0
npm ERR! npm v3.8.7
npm ERR! path d:\workspace\DomainJumper\GUI\node_modules.staging\abbrev-7e384210
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'd:\workspace\DomainJumper\GUI\node_modules.staging\abbrev-7e384210' -> 'd:\workspace\DomainJumper\GUI\node_modules\ember-cli\node_modules\npm\node_modules\abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename 'd:\workspace\DomainJumper\GUI\node_modules.staging\abbrev-7e384210' -> 'd:\workspace\DomainJumper\GUI\node_modules\ember-cli\node_modules\npm\node_modules\abbrev'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! Please include the following file with any support request:
npm ERR! d:\workspace\DomainJumper\GUI\npm-debug.log
When i run:
ng serve
module.js:327
throw err;
^
Error: Cannot find module 'semver'
at Function.Module._resolveFilename (module.js:325:15)
at Function.Module._load (module.js:276:25)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
hmmpf
package.json says:
"typescript": "^2.0.0"
Why????
I Change it to
"typescript": "^1.8.10".
Next try
ng version works now
ng serve throws error:
ERROR in ./src/main.ts
Module build failed: TypeError: this.ts.getAutomaticTypeDirectiveNames is not a function
at State.loadTypesFromConfig (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\host.ts:148:36)
at new State (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\host.ts:142:14)
at Object.ensureInstance (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\instance.ts:150:19)
at compiler (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\index.ts:37:20)
at Object.loader (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\index.ts:18:18)
@ multi main
ERROR in ./src/polyfills.ts
Module build failed: TypeError: this.ts.getAutomaticTypeDirectiveNames is not a function
at State.loadTypesFromConfig (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\host.ts:148:36)
at new State (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\host.ts:142:14)
at Object.ensureInstance (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\instance.ts:150:19)
at compiler (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\index.ts:37:20)
at Object.loader (d:\workspace\DomainJumper\GUI\node_modules\awesome-typescript-loader\src\index.ts:18:18)
run ng init
ng serve works. PUH! hard work.
I am seeing the same or similar problem on mac. I have attached the npm debug file
npm-debug.txt
I found (for me) followed solution:
Just short my last post.
clone project
npm i
npm install --save-dev angular-cli@webpack
ng init (no overwrite)
i find out that you need node v4.x to get it work, (had this problem with a team member)
regards
So I ended up taking a look at this again, since it would be preferable if I could get my desktop to run angular-cli vs my laptop.
I went ahead and uninstalled nodejs and wiped anything npm from appdata/roaming. Then installed the exact versions of Node.js (6.1.0) and npm (3.10.6) that my laptop has. Then attempting to install Angular-cli on the version of 1.0.0-beta.11-webpack.
I managed to watch the install closely this time and noticed some errors, that I haven't seen before on my laptop... Below are images of the errors
The first was an error then followed by a ton of warnings, that I have never noticed

The second is a much larger error

Still ending up with the same 'portfinder' error when I attempt ANY ng commands, such as just typing ng by itself and hitting enter, ng init, ng new test_prog, ng -v, etc...
So I had this same issue during a project upgrade and resolved by going through a few hoops...
npm installng init with no issues@bbohling Did something similar to what you suggested, as I don't even have a project created yet since I cannot run any commands. I went to where my angular-cli was installed globally, appdata/roaming/npm/node_modules, and ran npm install there. Unfortunately I still get the above npm install errors and the portfinder error outlined in the images of my previous comment...
Sorry @zjkipping I should have explicitly stated that I navigated not to the global angular-cli instance, but my local (project) instance.
I got the same problem and I solved the issue for me by going to my angular-cli folder and installing portfinder there with npm install portfinder it's working now but not sure why I got the error. My colleagues have a very similar setup (mac, node 6.5.0, npm 3.10.6) and they didn't get this error.
I can reproduce this by wiping angular-cli or node modules and reinstalling
If a local npm install portfinder fails to fix the issue, a global install of portfinder works.
Thank @retallicka and @jodytate for the very helpful answers. This seems to have done the trick for me. I can now run ng perfectly fine outside of another older angular-cli webpack project. I believe this problem is just that I am now on a newer version of the cli (beta.11-webpack.8) vs when I created it in the early days of beta.11-webpack.2. I'll go ahead and close this since my issues have been resolved.
Worked for me thanks 馃憤
cd your_project_folder
Then :
npm install --save-dev angular-cli@webpack
ng init
@retallicka @jodytate followed both steps, but doesn't works on my MAC
@jodytate
npm install portfinder solved the problem on my MAC.
Please install those dependence manually such as reflect-metadata and portfinder globally.
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._
Most helpful comment
If a local
npm install portfinderfails to fix the issue, a global install of portfinder works.