我正在创建一个以NodeJS为后端的Blockly项目。当我包含blockly_compress.js文件时,出现此错误:
/Users/camden/blockly/blocks_compressed.js:5
Blockly.Blocks.colour={};Blockly.Constants={};Blockly.Constants.Colour={};Blockly.Constants.Colour.HUE=20;
^
TypeError: Cannot set property 'colour' of undefined
at Object.<anonymous> (/Users/camden/blockly/blocks_compressed.js:5:22)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
at Module.load (internal/modules/cjs/loader.js:628:32)
at Function.Module._load (internal/modules/cjs/loader.js:555:12)
at Module.require (internal/modules/cjs/loader.js:666:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/Users/camden/backend.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:759:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
奇怪的是,它昨天起作用了,但是今天突然失效了。这是Node的某种错误吗?
编辑:这是引发错误的代码:
global.Blockly = require('./blockly/blockly_compressed.js');
require('./blockly/blocks_compressed.js');
require('./blockly/javascript_compressed.js');