Skip to content

Error: Cannot find module 'portfinder' with Webpack release and NPM 2 #1770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bisubus opened this issue Aug 19, 2016 · 7 comments
Closed

Error: Cannot find module 'portfinder' with Webpack release and NPM 2 #1770

bisubus opened this issue Aug 19, 2016 · 7 comments

Comments

@bisubus
Copy link

bisubus commented Aug 19, 2016

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Windows 7

  1. Versions. Please run ng --version. If there's nothing outputted, please run
    in a Terminal: node --version and paste the result here:

angular-cli: 1.0.0-beta.11-webpack.2
node: 6.2.2
npm: 2.15.6

  1. Repro steps. Was this an app that wasn't created using the CLI? What change did you
    do on your code? etc.

npm i -g [email protected]
ng

  1. The log given by the failure. Normally this include a stack trace and some
    more information.
Error while running script "C:\Program Files (x86)\nodejs\node_modules\angular-cli\addon\ng2\commands\serve.ts":
Error: Cannot find module 'portfinder'
    at Function.Module._resolveFilename (module.js:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\angular-cli\addon\ng2\commands\serve.ts:6:18)
    at Module._compile (module.js:541:32)
    at Object.require.extensions..ts (C:\Program Files (x86)\nodejs\node_modules\angular-cli\lib\cli\index.js:29:14)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Class.module.exports.includedCommands (C:\Program Files (x86)\nodejs\node_modules\angular-cli\addon\ng2\index.js:16:16)
    at C:\Program Files (x86)\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 (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:391:15)
    at Project.eachAddonCommand (C:\Program Files (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:426:30)
    at module.exports (C:\Program Files (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
    at CLI.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\cli.js:34:26)
    at lib$rsvp$$internal$$tryCatch (C:\Program Files (x86)\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 (x86)\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 (x86)\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:440:15)
    at Function.Module._load (module.js:388:25)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\angular-cli\addon\ng2\commands\serve.ts:6:18)
    at Module._compile (module.js:541:32)
    at Object.require.extensions..ts (C:\Program Files (x86)\nodejs\node_modules\angular-cli\lib\cli\index.js:29:14)
    at Module.load (module.js:458:32)
    at tryModuleLoad (module.js:417:12)
    at Function.Module._load (module.js:409:3)
    at Module.require (module.js:468:17)
    at require (internal/module.js:20:19)
    at Class.module.exports.includedCommands (C:\Program Files (x86)\nodejs\node_modules\angular-cli\addon\ng2\index.js:16:16)
    at C:\Program Files (x86)\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 (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:391:15)
    at Project.eachAddonCommand (C:\Program Files (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\models\project.js:426:30)
    at module.exports (C:\Program Files (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\lookup-command.js:33:13)
    at CLI.<anonymous> (C:\Program Files (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\lib\cli\cli.js:34:26)
    at lib$rsvp$$internal$$tryCatch (C:\Program Files (x86)\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 (x86)\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 (x86)\nodejs\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
  1. Mention any other details that might be useful.

The problem occurs with Webpack release and NPM 2. ember-cli depends on portfinder package and has it in node_modules after installation, but angular-cli expects portfinder to be located in its node_modules .
The problem can be solved by installing portfinder package manually in angular-cli or parent node_modules directory.

@cmjacques
Copy link

I had the same issue and needed to update npm.
npm install -g npm@latest

@bisubus
Copy link
Author

bisubus commented Aug 19, 2016

@cmjacques It upgrades NPM to 3. The issue applies to NPM 2.x which may be used on purpose.

@filipesilva
Copy link
Contributor

NPM3 is needed, yes. #1748 adds that requirement to the README.

@bisubus
Copy link
Author

bisubus commented Aug 23, 2016

@filipesilva But it works flawlessly with NPM 2 in other respects. Relying on portfinder in root node_modules while it is a dependency of child dependency (ember-cli) looks like a bug to me, which is concealed by NPM 3 directory structure.

Forcing NPM 3 for globally installed packages is the last thing the one may want, because it turns global node_modules into a big mess, it is impossible to say which packages were originally installed with -g.

@filipesilva
Copy link
Contributor

I'm sorry but there is just no way around NPM3. It's a hard dependency, and it has nothing to do with ember-cli actually. You can always use npm list -g --depth=0 to see your global package list.

@vcernomschi
Copy link

+1

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants