Skip to content

Webpack Plugin fails to import on Node 4 #6608

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
trickeyone opened this issue Jun 7, 2017 · 5 comments · Fixed by #9074
Closed

Webpack Plugin fails to import on Node 4 #6608

trickeyone opened this issue Jun 7, 2017 · 5 comments · Fixed by #9074

Comments

@trickeyone
Copy link

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

node: v4.8.3
npm: 5.0.3

Repro steps.

Just attempting to import the plugin using node v4 causes the error.

The log given by the failure.

/path/to/code/node_modules/@ngtools/webpack/src/plugin.js:8
const { __NGTOOLS_PRIVATE_API_2 } = require('@angular/compiler-cli');
      ^

SyntaxError: Unexpected token {
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    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)
    at Object.<anonymous> (/path/to/code/node_modules/@ngtools/webpack/src/index.js:30:10)
    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)
    at Object.<anonymous> (/path/to/code/webpack.config.js:3:19)
    at Module._compile (module.js:409:26)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] watch:js: `webpack --watch --progress --colors`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] build:js script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I tracked the change that's causing the issue to commit #507b39984ad71eab48bec1f933492acb653e90df

The package.json is indicating that this version is compatible with node >= 4.1.0

Desired functionality.

I tried changing the line to const __NGTOOLS_PRIVATE_API_2 = require('@angular/compiler-cli').__NGTOOLS_PRIVATE_API_2; but there were other instances:

  • line 67: const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
  • line 261: _translateSourceMap(sourceText, fileName, { line, character }) {
  • line 299: let { line, character, fileName } = this._translateSourceMap(sourceText, diagnostic.file.fileName, position);
  • line 368: const { line, character } = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);

Of which I started running into it in src/refactor.js and I couldn't keep tracking.

Mention any other details that might be useful.

I would rather not use a beta version, but it looks like that was the last time node 4 was actually supported.

@sumitarora
Copy link
Contributor

@trickeyone Angular CLI requires minimum node 6 or higher https://github.com/angular/angular-cli#prerequisites

@trickeyone
Copy link
Author

trickeyone commented Jun 24, 2017

Hi @sumitarora. Yes, I see that in the root project's requirements, however the @ngtools/webpack subproject has a requirement of node 4. See: https://github.com/angular/angular-cli/blob/master/packages/%40ngtools/webpack/package.json#L24

@trilokchandra
Copy link

Solved : you need to go to Tools/Options/Projects and Solutions/Web Package Management/External Web Tools and add C:\Program Files\nodejs to the locations of external tools. Then make sure it is at the top of the list.

@trickeyone
Copy link
Author

trickeyone commented Dec 29, 2017

@trilokchandra I'm on a Mac, not PC. I will follow-up that we have since moved to node v6. The main issue is that the required version of node was still set to v4 in the package.json for @ngtools/webpack . Updating the requirement should help keep anyone who is still on node < v6 from installing and getting errors.

@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 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants