Titanium JIRA Archive
Alloy (ALOY)

[ALOY-1705] Fix issue with return outside of function when using npm packages

GitHub Issuen/a
TypeBug
PriorityNone
StatusClosed
ResolutionFixed
Resolution Date2019-11-19T11:18:45.000+0000
Affected Version/sAlloy 1.14.1
Fix Version/sCLI Release 7.1.2
Componentsn/a
Labelsn/a
ReporterJason Kneen
AssigneeBrenton House
Created2019-09-24T13:43:44.000+0000
Updated2019-11-19T11:18:45.000+0000

Description

Test app attached 1. go to app/lib and run npm install 2. build app The app will fail with Alloy Compiler Failed error Run in trace mode shows an error however if you delete the folder app/lib/node_modules/bl/test, rebuild the App and it will build and launch in the simulato successfully. The error: {{[DEBUG] if (!process.env.SAUCE_KEY || !process.env.SAUCE_USER) [DEBUG] return console.log('SAUCE_KEY and/or SAUCE_USER not set, not running sauce tests') [DEBUG] if (!/v0\.10/.test(process.version)) [DEBUG] return console.log('Not Node v0.10.x, not running sauce tests') [DEBUG] require('./sauce.js') [DEBUG] [DEBUG] /Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/commands/compile/sourceMapper.js:212 [DEBUG] throw e; [DEBUG] ^ [DEBUG] SyntaxError: 'return' outside of function (4:2) [DEBUG] at Parser.raise (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:6325:17) [DEBUG] at Parser.parseReturnStatement (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:10190:12) [DEBUG] at Parser.parseStatementContent (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:9877:21) [DEBUG] at Parser.parseStatement (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:9829:17) [DEBUG] at Parser.parseIfStatement (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:10183:28) [DEBUG] at Parser.parseStatementContent (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:9874:21) [DEBUG] at Parser.parseStatement (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:9829:17) [DEBUG] at Parser.parseBlockOrModuleBlockBody (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:10405:25) [DEBUG] at Parser.parseBlockBody (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:10392:10) [DEBUG] at Parser.parseTopLevel (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:9758:10) [DEBUG] at Parser.parse (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:11270:17) [DEBUG] at Object.parse (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/@babel/parser/lib/index.js:11306:38) [DEBUG] at Object.exports.generateSourceMap (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/commands/compile/sourceMapper.js:206:17) [DEBUG] at /Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/utils.js:292:17 [DEBUG] at arrayEach (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/lodash/lodash.js:516:11) [DEBUG] at Function.forEach (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/lodash/lodash.js:9342:14) [DEBUG] at Object.exports.updateFiles (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/utils.js:249:4) [DEBUG] at updateFilesWithBuildLog (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/commands/compile/index.js:1114:24) [DEBUG] at /Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/commands/compile/index.js:263:3 [DEBUG] at arrayEach (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/lodash/lodash.js:516:11) [DEBUG] at Function.forEach (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/node_modules/lodash/lodash.js:9342:14) [DEBUG] at module.exports (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/commands/compile/index.js:262:4) [DEBUG] at Object. (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/Alloy/alloy.js:112:46) [DEBUG] at Module._compile (module.js:649:30) [DEBUG] at Object.Module._extensions..js (module.js:660:10) [DEBUG] at Module.load (module.js:561:32) [DEBUG] at tryModuleLoad (module.js:501:12) [DEBUG] at Function.Module._load (module.js:493:3) [DEBUG] at Module.require (module.js:593:17) [DEBUG] at require (internal/module.js:11:18) [DEBUG] at Object. (/Users/jkneen/.nvm/versions/node/v9.9.0/lib/node_modules/alloy/bin/alloy:3:1) [DEBUG] at Module._compile (module.js:649:30) [DEBUG] at Object.Module._extensions..js (module.js:660:10) [DEBUG] at Module.load (module.js:561:32) [DEBUG] at tryModuleLoad (module.js:501:12) [DEBUG] at Function.Module._load (module.js:493:3) [DEBUG] at Function.Module.runMain (module.js:690:10) [DEBUG] at startup (bootstrap_node.js:194:16) [DEBUG] at bootstrap_node.js:666:3 [ERROR] Alloy compiler failed}}

Attachments

FileDateSize
npmtest.zip2019-09-24T13:45:35.000+00008849395

Comments

  1. Brenton House 2019-09-24

    Created PR: https://github.com/appcelerator/alloy/pull/938
  2. Samir Mohammed 2019-11-19

    *Closing ticket.* Fix verified in CLI Version "NPM":"4.2.15-1","CLI":"7.1.2-7". Tested using the instructions above and no longer get the above error. *Test Environment*
       MacOS Catalina 10.15.1 beta
       Xcode 11 
       Node.js 10.16.3
       iPhone 7 Sim(12.2)
       "NPM":"4.2.15-1","CLI":"7.1.2-7"
       SDK Version 8.1.1.GA
       

JSON Source