AnsweredAssumed Answered

"ReferenceError: document is not defined" occurred when generate custom build of API

Question asked by okiwill on Mar 18, 2018
Latest reply on Mar 19, 2018 by odoe

I'm following this instruction(Using Bower for Custom Builds | ArcGIS API for JavaScript 4.6 ) to generate a custom build(RequireJS) of API, but this error occured:

 

 

Running "requirejs:single" (requirejs) task
ReferenceError: document is not defined
In module tree:
dojo/NodeList-dom
dojo/dom-construct
dojo/dom-attr
dojo/dom-prop
dojo/_base/connect
dojo/on
dojo/has

{ Error: ReferenceError: document is not defined
In module tree:
dojo/NodeList-dom
dojo/dom-construct
dojo/dom-attr
dojo/dom-prop
dojo/_base/connect
dojo/on
dojo/has

at /Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:28326:19
at /Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:3059:39
at /Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:2999:25
at Function.prim.nextTick (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:28077:9)
at Object.errback (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:2998:26)
at Object.callback (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:2984:23)
at Object.then (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:3038:23)
at build (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:28283:12)
at runBuild (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:30291:17)
at Object.execCb (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:1946:33)
at Module.check (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:1133:51)
at Module.enable (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:1426:22)
at Module.init (/Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:1038:26)
at /Users/Nie/custom-jsapi/4.x/bower/requirejs/node_modules/requirejs/bin/r.js:1710:36
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

I'm working on a Mac and installed these tools:

➜ requirejs git:(master) ✗ node --version
v9.1.0
➜ requirejs git:(master) ✗ git --version
git version 2.10.1
➜ requirejs git:(master) ✗ grunt --version
grunt-cli v1.2.0
grunt v1.0.2
➜ requirejs git:(master) ✗ bower --version
1.8.2
➜ requirejs git:(master) ✗ java -version
java version "1.8.0_45"
Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)

After git clone from GitHub, I have executed 'npm install' and added these lines at the top of app/main.js:

var dojoConfig = {
baseUrl: '.',
packages: [
'app',
'dijit',
'dojo',
'dojox',
'dstore',
'dgrid',
'esri'
]
};

Then this error occurred when execute 'npm run build'.

 

Anyone has some clues?

Outcomes