Comments (5)
import stripAnsi from 'strip-ansi'
. It only exports a function. Maybe have a look here for more info https://github.com/DefinitelyTyped/DefinitelyTyped/tree/f2b6506ba550e909224e43ecd07e15bbfbfbfce3/types/strip-ansi.
from strip-ansi.
@kevva Thanks for your quick answer! Unfortunately, it doesn't work... import stripAnsi from "strip-ansi";
results in strip_ansi_1.default is not a function
. If I import the function using const stripAnsi = require("strip-ansi");
, it works. Not sure why it doesn't with ES6 imports.
from strip-ansi.
Because CommonJS and modules works differently. It's like when you're requiring a module in CommonJS where you have to write:
const module = require('module').default;
from strip-ansi.
I see. Is there any way that I can import this module using ES6 module syntax?
Alternatively, changing the module to:
module.exports = {
stripAnsi: function (str) {
return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
}
};
allows to use (in TypeScript)
import * as stripAnsi from 'strip-ansi';
as well as (in JavaScript)
const stripAnsi = require('strip-ansi');
I'm not sure if this might cause any troubles in other packages. If not, I would create a pull request for this change if you're okay with it.
from strip-ansi.
We're not going to change just because you use TypeScript. If you use TypeScript it's up to you to figure out how to use packages with it. This module is exported exactly like most npm packages.
from strip-ansi.
Related Issues (20)
- Support streams
- ie11 does not work HOT 1
- Unable to install HOT 1
- set title mode escape codes not stripped HOT 1
- es6 code not supported in some browsers HOT 1
- incomplete stripping? HOT 1
- suggestion: offer a "default" export option to increase compatibility with es6 HOT 2
- Unicode Character 'REPLACEMENT CHARACTER' HOT 1
- Pure ESM issues HOT 1
- Error when starting a ts program in ts-node HOT 1
- Update ansi-regex in version 6 HOT 3
- There's a Regular Expression Denial of Service vulnerability in the ansi-regex package in versions < 6.0.1: HOT 7
- Add notes about non-esm version in readme HOT 3
- Does not strip `ESC ]0;<TEXT> BEL`
- [Feature Request] Add ability to only strip some ANSI codes HOT 1
- release github release HOT 3
- Upgrade dependencies for vulnerability fix HOT 1
- I didnt find jest-junit latest version updated with latest strip ansi 7.0.1 HOT 1
- License not readable HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from strip-ansi.