question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

require not working

See original GitHub issue

Bug Report or Feature Request (mark with an x)

  • bug report -> please search issues before submitting
  • feature request

Versions.

@angular/cli: 1.0.0 node: 6.9.4 os: win32 x64

Repro steps.

run ng new angular-cli-require-test add const requireTest = require('@angular/common'); in AppModule run ng build

The log given by the failure.

ERROR in C:/Sandboxes/Research/angular-cli-require-test/src/app/app.module.ts (8,19): Cannot find name ‘require’.

Desired functionality.

I would like to see require work in an angular-cli project.

Mention any other details that might be useful.

I need require to set up highcharts per documentation

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
vmasekcommented, Apr 3, 2017

Until this issue is resolved you can workaround it by declaring it. declare const require: any;

1reaction
filipesilvacommented, May 4, 2017

Overall, whenever you need to do const lib = require('lib') you can instead do import * as lib from 'lib';.

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - require not working as expected - Stack Overflow
It's because you're trying to load a node module that has not been installed. Sometimes too, other dependencies ...
Read more >
Javascript - How to fix ReferenceError: require is not defined
Fix require is not defined in a browser. The JavaScript require() function is only available by default in Node.js environment. This means the ......
Read more >
Fix "require is not defined" in JavaScript/Node - Stack Abuse
The require method is not available in the browser. To solve this, you have a few options, a few of which we'll briefly...
Read more >
Common Errors - RequireJS
Module name ... has not been loaded yet for context: ...§ 4 ; //If this code is not in a define call, //DO...
Read more >
How to fix the error `require is not defined` in Node.js
Today I started writing a new project on Node.js and got this error on the very first run: const express = require('express'); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found