Features
Games
Add-ons
Docs
Pricing
Forums
Blog
Log in
Sign Up

Features

Games

Add-ons

Docs

Pricing

Support

Blog

Log in

Sign Up

  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges
  • Home /
  • General Discussion /
avatar image
Question by celialegend · Dec 06, 2018 at 05:22 PM · CloudScript

ReferenceError: define is not defined at Script Document

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 !

Comment

People who like this

0 Show 14
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SethDu · Dec 07, 2018 at 08:53 AM 0
Share

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.

avatar image celialegend SethDu · Dec 07, 2018 at 10:59 AM 0
Share

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!

avatar image celialegend SethDu · Dec 07, 2018 at 11:10 AM 0
Share

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.

avatar image Andy ♦♦ celialegend · Dec 07, 2018 at 08:36 PM 1
Share

Are you, by any chance, importing anything in your typescript? I believe that won't work without taking additional steps.

Show more comments
Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment
celialegend

People who like this

1 Show 0 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    Time Locked Items 3 Answers

    Cloudscript and receiving a callback from Mopub's Rewarded Video Ads 1 Answer

    Is there any way to Create a character with data on it, similar to the grant items to users api call? 1 Answer

    CloudScript execution time includes server warmup 1 Answer

    [BUG] PlayFabError "EmailAddressNotAvailable" does not print friendly msg in C# return with Unity 1 Answer

    Tickets

    Need help with a confidential issue? We've got your back!

  • Create Ticket
  • View Open Tickets
  • Stay up-to-date with the latest from PlayFab:  
    Sign up for newsletter
    Engineers
    • Documentation
    • Tutorials
    • API Reference
    • SDKs
    • Usage Limits
    PLAYFAB
    • Features
    • Games
    • Add-ons
    • Pricing
    Support
    • Forums
    • Videos
    • File a Ticket
    • Service Health
    • Blog
    About
    • About
    • Jobs
    • Contact
    • Press Room
    • Privacy Policy
    • Terms of Service
    • Acceptable Use
    • Style Guide
     
     
    Sign Up

    ©2017 PlayFab, Inc.

    ©2016 PlayFab, Inc. All rights reserved. PlayFab® is a registered trademark of PlayFab, Inc. | Privacy | Terms | Acceptable Use
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Post an idea
    • Create an article
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges