javascript imports errors
-
Hello,
i'm creating a small app using 'pyside2 + qml' to test and learn
it has 2 files# main.py from PySide2.QtWidgets import QApplication from PySide2.QtQml import QQmlApplicationEngine if __name__ == "__main__": app = QApplication([]) engine = QQmlApplicationEngine() engine.load('./view.qml') app.exec_()
# view.qml import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Window 2.2 import "axios.min.js" as Axios
i'm trying to import some javascript libraries to test them inside my app but i got some errors:
- when i import axios v0.21.1 : it works fine
- but when i import axios new versions ( >0.21.1) it doesn't work and i get an error
TypeError: Value is null and could not be converted to an object
i tested different libraries like vanillajs and cheerio but getting errors too:
- vanilla:
ReferenceError: exports is not defined
- cheerio:
ReferenceError: exports is not defined
Any solution?
or in other words, how to use nodejs libraries with qml ?Note: the JS files are taken from jsdelivr cdn
Thank you
-
@mIcHyAmRaNe said in javascript imports errors:
- when i import axios v0.21.1 : it works fine
- but when i import axios new versions ( >0.21.1) it doesn't work and i get an error
TypeError: Value is null and could not be converted to an object
It sounds like there were some backward-incompatible changes for versions >0.21.1
Where is the null value?
i tested different libraries like vanillajs and cheerio but getting errors too:
- vanilla:
ReferenceError: exports is not defined
- cheerio:
ReferenceError: exports is not defined
Any solution?
or in other words, how to use nodejs libraries with qml ?If I'm not mistaken,
exports
are NodeJS extensions, not part of ECMAScript (i.e. standard JavaScript). Qt's JavaScript engine supports ECMAScript 7 as of Qt 5.12.