i got this error after i upload my main.js which compiled by my typescript files, my tsconfig.json below:
{ "compilerOptions": { "module": "amd", "removeComments": true, "preserveConstEnums": true, "forceConsistentCasingInFileNames": true, "sourceMap": true, "rootDir": "./", "outFile": "./dist/main.js", "baseUrl": "./modules/" } }
there is something like this in js file below:
define("modules/INTERFACES", ["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); });
then i got Error
ReferenceError: define is not defined at Script Document.
thanks for any advice !
May I ask are you trying to implement Node.js SDK?
''define is not defined" issue normally should be a tsconfig.json file issue where you set up function modules and yes, your troubleshooting directions should be correct. But we'd like to inform you that we only support PlayFab related issue in the community forum. We suggest you post a thread in a Node.js specialized forum for help.
thanks for your response, the problem is playfab only supports one js file about cloud script, so i have to compile my js files into one js file. i also tried another solution: i pushed all js files into github, and plabfab combined it automatically, my tsconfig.json is something like below
{ "compilerOptions": { "target": "es5", "module": "commonjs", "lib": [ "es2015", "es5"], "removeComments": true, "preserveConstEnums": true, "forceConsistentCasingInFileNames": true, "rootDir": "./", "outDir": "./dist", "baseUrl": "./" } }
but it issues another problem, there will be one line: Object.defineProperty(exports, "__esModule", { value: true }); in the first line of my js file, and then playfab got error below:
ReferenceError: exports is not defined !
thanks for any advices!
by the way, i am not trying to implement Node.js SDK, i am writing typescript code, and then compile them into js file, and then upload it on playfab.
Are you, by any chance, importing anything in your typescript? I believe that won't work without taking additional steps.
Answer by celialegend · Dec 12, 2018 at 02:45 AM
i found the solution, i added the RequireJs file manually into my final one single js file, and the "define" keyword works, everything is going well now, cheers.