Tôi không chắc chắn về những gì có thể gây ra lỗi này trong Node.js, như tôi chưa từng thấy trước đây và không thể tìm thấy vấn đề khác trực tuyến.Mã thông báo không mong muốn =
Message:
Unexpected token =
Stack:
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:404:25)
at Object.Module._extensions..js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (/Projects/api/test/integration/models/article.js:3:15)
Các tập tin đó gây ra các lỗi có các nội dung sau:
'use strict';
var Article = require('../../../models/article')
Tại sao trên thế giới sẽ =
gây ra một lỗi?
Sửa 1 - thêm article.js đang được yêu cầu:
'use strict';
class ArticleModel {
constructor(options = {}) {
this.options = options
}
}
module.exports = ArticleModel
nó có thể không đã tìm thấy các tập tin. Đôi khi nó cung cấp cho bạn một thông báo lỗi và được giải thích khá bất thường – MiltoxBeyond
Bạn không cần một dấu chấm phẩy ở cuối? – gariepy
Đó có phải là toàn bộ tệp không? Nếu một tập tin không được tìm thấy, bạn sẽ nhận được một lỗi như thế này: 'Lỗi: Không thể tìm thấy mô-đun '. Ngoài ra, nó có thể là một số unicode kỳ lạ = như nhân vật? – EmptyArsenal