winston: Winston 3 and create-react-app throws Uncaught ReferenceError: stream is not defined
Please tell us about your environment:
winston
version? winston@3node -v
outputs: v10.11.0- Operating System? macOS
- Language? ES6/7
What is the problem?
I create a new application with create-react-app and install winston 3.1.0 with npm install winston --save
.
After that I create a new file called myLogger.js
and write logger from the quickstart:
import winston from 'winston';
const myLogger = winston.createLogger({
level: 'info',
format: winston.format.json(),
transports: [
new winston.transports.Console({
format: winston.format.simple()
})
]
});
//
// If we're not in production then log to the `console` with the format:
// `${info.level}: ${info.message} JSON.stringify({ ...rest }) `
//
if (process.env.NODE_ENV !== 'production') {
myLogger.add(
new winston.transports.Console({
format: winston.format.simple(),
level: 'debug'
})
);
}
export default myLogger;
After that I import the logger in the create-react-app created App.js:
import myLogger from './myLogger';
export default class App extends Component {
componentDidMount() {
myLogger.debug('Mounted!');
}
render() {return (</div>)}
}
If I start now the development server I get the error:
ReferenceError: stream is not defined
(anonymous function)
node_modules/winston/lib/winston/logger.js:631
628 | }]);
629 |
630 | return Logger;
> 631 | }(stream.Transform);
632 |
What do you expect to happen instead?
It just works on a freshly started create-react-app đŸ˜„
Other information
Here is the full stack:
logger.js:631 Uncaught ReferenceError: stream is not defined
at Object.<anonymous> (logger.js:631)
at Object../node_modules/winston/lib/winston/logger.js (logger.js:656)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Object../node_modules/winston/lib/winston/create-logger.js (create-logger.js:24)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Object../node_modules/winston/lib/winston.js (winston.js:55)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Module../src/myLogger.js (myLogger.js:1)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Module../src/App.js (App.css?da7c:45)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Module../src/index.js (index.css?02e3:45)
at __webpack_require__ (bootstrap:782)
at fn (bootstrap:150)
at Object.0 (serviceWorker.js:127)
at __webpack_require__ (bootstrap:782)
at checkDeferredModules (bootstrap:45)
at Array.webpackJsonpCallback [as push] (bootstrap:32)
at main.chunk.js:1
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 2
- Comments: 25 (7 by maintainers)
Getting this error with Winston 3.2.
Uncaught TypeError: fs.existsSync is not a function at File._createLogDirIfNotExist (file.js:804) at new File (file.js:132) at Object.<anonymous> (mylogger.js:16) at webpack_require (bootstrap 284d16fcfe1dcfa44176:676) at fn (bootstrap 284d16fcfe1dcfa44176:87) at Object.<anonymous> (mymodule.js:5) at webpack_require (bootstrap 284d16fcfe1dcfa44176:676) at fn (bootstrap 284d16fcfe1dcfa44176:87) at Object.<anonymous> (app.js:21) at webpack_require (bootstrap 284d16fcfe1dcfa44176:676)
logform and winston-transport are transpiled too on master — all the Winston packages will receive a bump to npm when we publish
Bump to have this active in current version @winstonjs
@kibertoad actually it was fixed with 3.2.0 that’s why I deleted my comment, thanks!
You can always reference master in your package.json instead of a version number. We are hoping to publish 3.2.0 on 12/23 if no surprises come up in the maintainers’ schedules.