lukeed / taskr

A fast, concurrency-focused task automation tool.
MIT License
2.53k stars 74 forks source link

fly + fly-esnext pairing doesn't work globally #159

Closed mtimofiiv closed 7 years ago

mtimofiiv commented 8 years ago

There's something funky going on with fly and fly-esnext. When I install everything correctly, that being the latest versions of both in my dependencies/dev-dependencies, and install fly globally so I can run the commands, I get this error popping up when I try to run fly:

stack: 
  - Error: Cannot find module 'fly-esnext'
  -     at Function.Module._resolveFilename (module.js 339:15)
  -     at Function.Module._load (module.js 290:25)
  -     at Module.require (module.js 367:17)
  -     at require (internal/module.js 16:19)
  -     at parse (~/.nvm/versions/node/v5.10.1/lib/node_modules/fly/lib/plugins.js 94:3)
  -     at ~/.nvm/versions/node/v5.10.1/lib/node_modules/fly/lib/plugins.js 28:10
message: Cannot find module 'fly-esnext'
code:    MODULE_NOT_FOUND

I went through some of the issues here and it seems that the newest version of Babel has broken things. But I haven't seen any bugs posted yet with this error in particular.

Thoughts?

lukeed commented 8 years ago

Have you tried installing fly-esnext globally?

Personally I haven't tested globals yet, but I know Fly and fly-esnext have to be siblings

lukeed commented 8 years ago

Hi @mtimofiiv, have you tried my suggestion?

mtimofiiv commented 8 years ago

@lukeed I tried this - and now I get the following:

stack: 
  - SyntaxError: Unexpected token import
  -     at exports.runInThisContext (vm.js 53:16)
  -     at Module._compile (module.js 387:25)
  -     at Object.Module._extensions..js (module.js 422:10)
  -     at Module.load (module.js 357:32)
  -     at Function.Module._load (module.js 314:12)
  -     at Module.require (module.js 367:17)
  -     at require (internal/module.js 16:19)
  -     at Object.module.exports [as spawn] (~/.nvm/versions/node/v5.10.1/lib/node_modules/fly/lib/cli/spawn.js 22:9)
  -     at next (native)
  -     at onFulfilled (~/.nvm/versions/node/v5.10.1/lib/node_modules/fly/node_modules/co/index.js 65:19)
message: Unexpected token import

My first line in the Flyfile.js is this:

import dotenv from 'dotenv';

So I would imagine this is not Babelizing the Flyfile.

lukeed commented 8 years ago

Ok. Please post your Fly and Node versions and I will attempt to replicate this. :+1:

mtimofiiv commented 8 years ago

Tried on node 5.6.0 and 5.10.1. Fly version 1.2.0.

lukeed commented 8 years ago

Thanks! Will check it today

mtimofiiv commented 8 years ago

Hi @lukeed, any progress? I'm currently using version 0.9.1 and have tested the latest build again and am still getting the Unexpected token import

lukeed commented 8 years ago

Hey @mtimofiiv, sorry for the delay.

I just tried. I got it working on Node 6.1 with Fly 1.3

If you want to continue using Fly globally and also want to use fly-esnext for the ES2015+ syntax, you have to install fly-esnext locally.

It sounds weird, I know, but Fly only looks for fly-esnext if it's listed as a dependency in your package.json file.

So, assuming you already have a package.json file in your project:

npm i -g fly
npm i fly-esnext --save-dev

You will have to install fly-esnext locally & include it on your package.json for every project.

I'll find a way to fix this in future versions. 😄

mtimofiiv commented 8 years ago

Hi @lukeed,

I have done this. I am now on node 6.0.0 and fly (global) version 1.3.0 and have the latest fly-esnext installed locally.

Globally running fly now results in this:

stack: 
  - Error: Cannot find module 'fly-esnext'
  -     at Function.Module._resolveFilename (module.js 438:15)
  -     at Function.Module._load (module.js 386:25)
  -     at Module.require (module.js 466:17)
  -     at require (internal/module.js 20:19)
  -     at parse (~/.nvm/versions/node/v6.0.0/lib/node_modules/fly/lib/plugins.js 107:3)
  -     at ~/.nvm/versions/node/v6.0.0/lib/node_modules/fly/lib/plugins.js 33:11
message: Cannot find module 'fly-esnext'
code:    MODULE_NOT_FOUND

The error still seems to be the same, that global fly seems to be looking for the global fly-esnext. When I try installing fly locally and running it via node ./node_modules/fly/lib/index.js so both are in the same place, I get this:

stack: 
  - TypeError: Cannot read property 'error' of undefined
  -     at OptionManager.mergeOptions (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js 126:28)
  -     at OptionManager.addConfig (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js 107:10)
  -     at OptionManager.findConfigs (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js 168:35)
  -     at OptionManager.init (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/transformation/file/options/option-manager.js 229:12)
  -     at compile (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/api/register/node.js 117:22)
  -     at normalLoader (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/api/register/node.js 199:14)
  -     at Object.require.extensions.(anonymous function) [as .js] (~/dev/pinmark/frontend/node_modules/babel/node_modules/babel-core/lib/api/register/node.js 216:7)
  -     at Module.load (module.js 456:32)
  -     at tryModuleLoad (module.js 415:12)
  -     at Function.Module._load (module.js 407:3)
message: Cannot read property 'error' of undefined

I tried installing both locally just to test to see what would happen, since sometimes with certain tools it seems to help to run the local copy.

mtimofiiv commented 8 years ago

Here is a sample repo: https://github.com/mtimofiiv/fly-esnext-issue

What I do:

npm install
npm install -g fly
fly

This results in:

stack: 
  - Error: Cannot find module 'fly-esnext'
  -     at Function.Module._resolveFilename (module.js 440:15)
  -     at Function.Module._load (module.js 388:25)
  -     at Module.require (module.js 468:17)
  -     at require (internal/module.js 20:19)
  -     at parse (~/.nvm/versions/node/v6.3.0/lib/node_modules/fly/lib/plugins.js 107:3)
  -     at ~/.nvm/versions/node/v6.3.0/lib/node_modules/fly/lib/plugins.js 33:11
message: Cannot find module 'fly-esnext'
code:    MODULE_NOT_FOUND

The line where this error pops up is lib/plugins.js#L107.

This is on node version 6.3.0.

lukeed commented 8 years ago

You have to install both globally if you want global usage.

lukeed commented 7 years ago

@mtimofiiv I'm sorry for the delay & the confusion! 😿

The fly-esnext package (currently) doesn't support import statements. You have to use require().

The reason I didn't think of this at first is because I originally did support import, but then removed it before publishing because it wasn't very consistent. I've created an issue & you can track its progress there.

Sorry again for the inconvenience.