cli icon indicating copy to clipboard operation
cli copied to clipboard

"Unexpected token import" when using symlinks

Open quooston opened this issue 7 years ago • 16 comments

I'm submitting a bug report

  • Library Version: CLI: 0.32.0

Please tell us about your environment:

  • Operating System: Windows 10 Pro

  • Node Version: 9.5.0

  • NPM Version: 5.6.0

  • Browser: N/A

  • Language: ESNext

  • Loader/bundler: SystemJS and RequireJS

Current behavior: au new --here does it's thing. After installing dependencies, I run au build, and get the error:

(function (exports, require, module, __filename, __dirname) { import gulp from 'gulp';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at new Script (vm.js:51:7)
    at createScript (vm.js:138:10)
    at Object.runInThisContext (vm.js:199:10)
    at Module._compile (module.js:624:28)
    at Module._extensions..js (module.js:671:10)
    at Object.require.extensions.(anonymous function) [as .js] (d:\code\scratch\meh\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)

I have just recently reformatted my machine, this is a fresh box with everything installed first time.

I have a .babelrc file (put there by the CLI):

{
  "sourceMap": true,
  "sourceRoot": "src",
  "moduleIds": false,
  "comments": false,
  "compact": false,
  "code": true,
  "presets": [
    ["es2015", {"loose": true}],
    "stage-1"
  ],
  "plugins": [
    "syntax-flow",
    "transform-decorators-legacy",
    "transform-flow-strip-types"
  ]
}
  • What is the expected behavior? I'd like it to build!

  • What is the motivation / use case for changing the behavior? :|

quooston avatar Feb 24 '18 10:02 quooston

Looks like it does not get transpiled correctly. I just tried on node 8.5 and it worked as it should. You can debug cli with vscode modify launch.json to add a configuration like this: `{ // Use IntelliSense to find out which attributes exist for node debugging // Use hover for the description of the existing attributes // For further information visit https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [

{
  "type": "node",
  "request": "launch",
  "name": "Debug CLI build",
  "program": "${workspaceFolder}/node_modules/aurelia-cli/bin/aurelia-cli.js",
  "args": [
    "build"
  ]
}

] } ` and step through

Alexander-Taran avatar Feb 24 '18 11:02 Alexander-Taran

@quooston have you been able to resolve your issue?

Alexander-Taran avatar Mar 08 '18 16:03 Alexander-Taran

No I haven't. My work machine is on an older version of Node and it worked there. So, there is some issue with the latest version(s).

Thanks for the tip though, I will try it at home.

Q

On 9 March 2018 at 03:57, Alexander-Taran [email protected] wrote:

@quooston https://github.com/quooston have you been able to resolve your issue?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/cli/issues/830#issuecomment-371550576, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD4tKzDIzlBbIJIZKGO4jHjDan7Iie7ks5tcWL6gaJpZM4SR1dx .

quooston avatar Mar 12 '18 09:03 quooston

@quooston might me npm issue btw. do you have yarn installed? If not can you try with installing yarn and rescaffolding with au new?

Alexander-Taran avatar Mar 12 '18 10:03 Alexander-Taran

Ok I'll give that a go.

On Mon, 12 Mar 2018, 21:19 Alexander-Taran, [email protected] wrote:

@quooston https://github.com/quooston might me npm issue btw. do you have yarn installed? If not can you try with installing yarn and rescaffolding with au new?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/cli/issues/830#issuecomment-372259287, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD4tCi--4F38CJDNmixvzPzm3d08OdQks5tdkumgaJpZM4SR1dx .

quooston avatar Mar 12 '18 22:03 quooston

Keep me posted (-:

Alexander-Taran avatar Mar 12 '18 23:03 Alexander-Taran

Unfortunately installing yarn did not resolve the issue. I also uninstalled node and installed 8.1 to no avail. It's a windows box, so I used the control panel to do those things.

So, I will try to debug it as you pointed out before and let you know how I go.

Thanks

On 13 March 2018 at 10:06, Alexander-Taran [email protected] wrote:

Keep me posted (-:

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/cli/issues/830#issuecomment-372491999, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD4tPp3G8ZOTl4aioaK5obt_rwbRGlnks5tdv-AgaJpZM4SR1dx .

quooston avatar Mar 15 '18 12:03 quooston

@quooston this one is very strange. Might also try on another box?

Alexander-Taran avatar Mar 15 '18 13:03 Alexander-Taran

Perhaps try a different folder as well, maybe on the C disk

JeroenVinke avatar Mar 18 '18 07:03 JeroenVinke

@quooston Another thought is that you might be behind a proxy. There is new version of CLI that just came out can you update yours and try again?

Alexander-Taran avatar Mar 19 '18 18:03 Alexander-Taran

same here.

Win7 / node-8.11.1 / npm-5.6.0 / au-0.33.1

I did

  • au new router-tutorial (default configuratino)
  • au build
d:\prj\study\aurelia\router2\aurelia_project\tasks\build.js:1
(function (exports, require, module, __filename, __dirname) { import gulp from 'gulp';
                                                              ^^^^^^

SyntaxError: Unexpected token import
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:616:28)
    at Module._extensions..js (module.js:663:10)
    at Object.require.extensions.(anonymous function) [as .js] (d:\prj\study\aurelia\router2\node_modules\babel-register\lib\node.js:152:7)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

au run did make same result. any hint or update? I'm just kicking in learning aurelia.

joonhwan avatar Apr 02 '18 09:04 joonhwan

@joonhwan looks like npm issue from here.. can we retrace your steps? I assume you installed aurelia-cli with npm i -g aurelia-cli then you ran au new something what were the choices?

also run where au from command line there might be more CLIs than you think of (-:

anyway try to update npm to latest (5.8 I think) with npm i -g npm and redo from scratch. all the scenarios should work. It is just a js program after all. external dependencies seem to fail more recently.. npm, webpack etc..

Alexander-Taran avatar Apr 02 '18 11:04 Alexander-Taran

Hi again,

No proxy here, I'm at home.

I've recently had to reinstall my box because my mobo died... and arrived at the exact same issue.

Q

On 20 March 2018 at 05:37, Alexander Taran [email protected] wrote:

@quooston https://github.com/quooston Another thought is that you might be behind a proxy. There is new version of CLI that just came out can you update yours and try again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/cli/issues/830#issuecomment-374320218, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD4tBllvK-yHRJ01fv4cDnFq_lk5bTnks5tf_rVgaJpZM4SR1dx .

quooston avatar Apr 10 '18 09:04 quooston

​where au => C:\Program Files\nodejs\au C:\Program Files\nodejs\au.cmd​

On 10 April 2018 at 19:46, Qerim Shahini [email protected] wrote:

Hi again,

No proxy here, I'm at home.

I've recently had to reinstall my box because my mobo died... and arrived at the exact same issue.

Q

On 20 March 2018 at 05:37, Alexander Taran [email protected] wrote:

@quooston https://github.com/quooston Another thought is that you might be behind a proxy. There is new version of CLI that just came out can you update yours and try again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/cli/issues/830#issuecomment-374320218, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD4tBllvK-yHRJ01fv4cDnFq_lk5bTnks5tf_rVgaJpZM4SR1dx .

quooston avatar Apr 10 '18 09:04 quooston

SOLVED!

It's a path issue.

My code is at c:\users\q\code... But that code folder is actually a symlink to e:\code.

When I run au build from c:\users\q\code... it fails. When I run au build from e:\code... it works!

Don't know why, but there you have it.

Q

On 10 April 2018 at 19:49, Qerim Shahini [email protected] wrote:

​where au => C:\Program Files\nodejs\au C:\Program Files\nodejs\au.cmd​

On 10 April 2018 at 19:46, Qerim Shahini [email protected] wrote:

Hi again,

No proxy here, I'm at home.

I've recently had to reinstall my box because my mobo died... and arrived at the exact same issue.

Q

On 20 March 2018 at 05:37, Alexander Taran [email protected] wrote:

@quooston https://github.com/quooston Another thought is that you might be behind a proxy. There is new version of CLI that just came out can you update yours and try again?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/aurelia/cli/issues/830#issuecomment-374320218, or mute the thread https://github.com/notifications/unsubscribe-auth/AAD4tBllvK-yHRJ01fv4cDnFq_lk5bTnks5tf_rVgaJpZM4SR1dx .

quooston avatar Apr 10 '18 09:04 quooston

@joonhwan do you also use symlinks ?

Alexander-Taran avatar Apr 10 '18 11:04 Alexander-Taran