私はnode.jsにいます私は2つのファイルを持っています。require()の識別子が未定義として報告されます
winston.js:
class Winston {
constructor(count) {
this.count = count
}
}
start.js
const winston = require('./winston')
let myWinston = new Winston(1)
私はstart.js、(ノード./start.jsに)
を実行すると、私はエラーを取得します:
ReferenceError: Winston is not defined
どのようにウィンストンファイルですか?
他のファイルに
export default
に必要な別のファイルから変数を取得する方法[これを試してみてくださいノードjsのファイル](https://stackoverflow.com/questions/7612011/how-to-get-a-variable-from-a-file-to-another-file-in-node-js) –最初に:あなた再インスタントWinston(タイトルケース)を起動し、winston(小文字)をインポートしています。 2番目:winston.jsからクラスをエクスポートする必要がある – Gerardo