Of course, it show 'v8.9.0'.
And I try run sudo ln -s /usr/bin/nodejs /usr/bin/node, after it tips that ln: failed to create symbolic link '/usr/bin/node': File exists
Of course, it show 'v8.9.0'.
And I try run `sudo ln -s /usr/bin/nodejs /usr/bin/node`, after it tips that `ln: failed to create symbolic link '/usr/bin/node': File exists`
Try starting the server without use of `npm` like this:
`node -r esm ./bin/server`
**Update:** here is why it doesn't work for you: `#!` does not allow passing multiple argument to the interpreter. More info here: https://unix.stackexchange.com/questions/63979/shebang-line-with-usr-bin-env-command-argument-fails-on-linux
This has worked for me locally (on my mac) for some time - is this specific to linux? Maybe some bash versions?
The -r esm is required for the import syntax I am using however I am happy to add a package.json launch script or other documentation to the readme to make launching the server clearer.
This has worked for me locally (on my mac) for some time - is this specific to linux? Maybe some bash versions?
The `-r esm` is required for the `import` syntax I am using however I am happy to add a package.json launch script or other documentation to the readme to make launching the server clearer.
Same here. Only I'm not running localtunnel server manually but via pm2. It errors with
/var/opt/localtunnel/localtunnel-server/bin/server:3
import 'localenv';
^^^^^^
SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:78:21)
at Module._compile (internal/modules/cjs/loader.js:654:30)
When I try to run it manually I get
/usr/bin/env: node -r esm: No such file or directory
Same here. Only I'm not running localtunnel server manually but via [pm2](/Unitech/PM2/). It errors with
```
/var/opt/localtunnel/localtunnel-server/bin/server:3
import 'localenv';
^^^^^^
SyntaxError: Unexpected token import
at new Script (vm.js:51:7)
at createScript (vm.js:136:10)
at Object.runInThisContext (vm.js:197:10)
at Module._compile (internal/modules/cjs/loader.js:618:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
at Module.load (internal/modules/cjs/loader.js:566:32)
at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
at Function.Module._load (internal/modules/cjs/loader.js:498:3)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:78:21)
at Module._compile (internal/modules/cjs/loader.js:654:30)
```
When I try to run it manually I get
```
/usr/bin/env: node -r esm: No such file or directory
```
@Spown try running directly through node node -r esm ./bin/server
if the first case, pm2 call doesn't include required library esm
if the second case, you are hitting the same problem as OP.
@Spown try running directly through node `node -r esm ./bin/server`
* if the first case, pm2 call doesn't include required library `esm`
* if the second case, you are hitting the same problem as OP.
You are right: I am not sure how pm2 works. I am just telling you what that error means. import is not available in nodejs 8 so one needs to load esm library before executing server script.
You are right: I am not sure how pm2 works. I am just telling you what that error means. `import` is not available in nodejs 8 so one needs to load `esm` library before executing `server` script.
@siburny No it's not working.
The only thing that worked for me (node 8) was to remove the shebang and put node -r esm ./bin/server inside the package.json as "start" shortcut.
@siburny No it's not working.
The only thing that worked for me (node 8) was to remove the shebang and put `node -r esm ./bin/server` inside the `package.json` as "start" shortcut.
I believe it's something highly pm2-specific, because I overcame this just by restarting/updating pm2: pm2 update. First I've added "node_args" : "-r esm" to my config file, but this also haven't worked out although I began to get another error. And only after restarting pm2 localtunnel started to work.
It may look silly, but judging by this pm2 issue pm2 may have some problem.
Anyway I've solved this problem without updating any of pm2 files, but just by changing pm2 config and restart
I believe it's something highly pm2-specific, because I overcame this just by restarting/updating pm2: `pm2 update`. First I've added `"node_args" : "-r esm"` to my config file, but this also haven't worked out although I began to get another error. And only after restarting pm2 localtunnel started to work.
It may look silly, but judging by [this pm2 issue](https://github.com/Unitech/pm2/issues/1943) pm2 may have some problem.
Anyway I've solved this problem without updating any of pm2 files, but just by changing pm2 config and restart
All the solutions above doesn't help me.
I'm really not an expert in this stuff, but I got an other solution.
I wrote a small script: #!/bin/bash cd <yourpath>/localtunnel-server node -r esm ./bin/server --port 1234
Of course <yourpath> must be adapted to your installation.
Starting the server with this script works fine for me.
Also starting this script with pm2 works for me.
All the solutions above doesn't help me.
I'm really not an expert in this stuff, but I got an other solution.
I wrote a small script:
`#!/bin/bash`
`cd <yourpath>/localtunnel-server`
`node -r esm ./bin/server --port 1234`
Of course `<yourpath>` must be adapted to your installation.
Starting the server with this script works fine for me.
Also starting this script with pm2 works for me.
All the solutions above doesn't help me.
I'm really not an expert in this stuff, but I got an other solution.
I wrote a small script: #!/bin/bash cd <yourpath>/localtunnel-server node -r esm ./bin/server --port 1234
Of course <yourpath> must be adapted to your installation.
Starting the server with this script works fine for me.
Also starting this script with pm2 works for me.
This is what worked for me. I had to change/add 'exec_interpreter' in my pm2.config.json file with value 'bash'. Also, for you to be able to connect to your lt server, you might need to change the above command as below: #!/bin/bash cd <your-tunnel-server-directory> node -r esm ./bin/server --port <YOUR PORT> --net host --domain <eg, sub.domain.com. Base domain/subdomain where you want your tunnelservert to be hosted>
> All the solutions above doesn't help me.
> I'm really not an expert in this stuff, but I got an other solution.
>
> I wrote a small script:
> `#!/bin/bash`
> `cd <yourpath>/localtunnel-server`
> `node -r esm ./bin/server --port 1234`
>
> Of course `<yourpath>` must be adapted to your installation.
>
> Starting the server with this script works fine for me.
> Also starting this script with pm2 works for me.
This is what worked for me. I had to change/add 'exec_interpreter' in my pm2.config.json file with value 'bash'. Also, for you to be able to connect to your lt server, you might need to change the above command as below:
`#!/bin/bash`
`cd <your-tunnel-server-directory>`
`node -r esm ./bin/server --port <YOUR PORT> --net host --domain <eg, sub.domain.com. Base domain/subdomain where you want your tunnelservert to be hosted>`
Had the issue with /usr/bin/env: node -r esm: No such file or directory and had it solved using node -r esm ./bin/server but now I'm getting this error with node 14.15.0:
file:///root/server/bin/server:1
SyntaxError: Error parsing /root/server/node_modules/localenv/package.json: Unexpected token , in JSON at position 1492
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) {
path: '/root/server/node_modules/localenv/package.json'
}
Any ideas?
Had the issue with `/usr/bin/env: node -r esm: No such file or directory` and had it solved using `node -r esm ./bin/server` but now I'm getting this error with node 14.15.0:
```
file:///root/server/bin/server:1
SyntaxError: Error parsing /root/server/node_modules/localenv/package.json: Unexpected token , in JSON at position 1492
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) {
path: '/root/server/node_modules/localenv/package.json'
}
```
Any ideas?
It looks like .json file is corrupt. Can you post it somewhere? Or use online JSON validator.
Update: I am referring to /root/server/node_modules/localenv/package.json file
It looks like .json file is corrupt. Can you post it somewhere? Or use online JSON validator.
*Update:* I am referring to `/root/server/node_modules/localenv/package.json` file
I took a good look at the file and it seems ok. I used JSON validators and JSON lint, it's all right.
The position mentioned (1492) in the error is the last byte of the file. It's exactly the file length and there is nothing at the end of the file, except for the closing brackets and EOF.
I took a good look at the file and it seems ok. I used JSON validators and JSON lint, it's all right.
The position mentioned (1492) in the error is the last byte of the file. It's exactly the file length and there is nothing at the end of the file, except for the closing brackets and EOF.
I was able to reproduce this error on the fresh installation. Version of esm module is outdated in package-lock.json. You should upgrade it with npm install esm@3, and then it will work fine.
I was able to reproduce this error on the fresh installation. Version of `esm` module is outdated in package-lock.json. You should upgrade it with `npm install esm@3`, and then it will work fine.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
When I run 'bin/server --port 1234', it gives errorr as the title descript.
And my system is Ubuntu 16.04.3 LTS
Can you run
node -vfrom the same folder?Of course, it show 'v8.9.0'.
And I try run
sudo ln -s /usr/bin/nodejs /usr/bin/node, after it tips thatln: failed to create symbolic link '/usr/bin/node': File existsTry starting the server without use of
npmlike this:node -r esm ./bin/serverUpdate: here is why it doesn't work for you:
#!does not allow passing multiple argument to the interpreter. More info here: https://unix.stackexchange.com/questions/63979/shebang-line-with-usr-bin-env-command-argument-fails-on-linuxThis has worked for me locally (on my mac) for some time - is this specific to linux? Maybe some bash versions?
The
-r esmis required for theimportsyntax I am using however I am happy to add a package.json launch script or other documentation to the readme to make launching the server clearer.Yes, it's specific to the Unix flavor.
Same here. Only I'm not running localtunnel server manually but via pm2. It errors with
When I try to run it manually I get
@Spown try running directly through node
node -r esm ./bin/serveresm@siburny that's not how pm2 does things. anyway I'm not in a hurry. I'm sure when the OP problem is fixed - pm2'll start working as well.
You are right: I am not sure how pm2 works. I am just telling you what that error means.
importis not available in nodejs 8 so one needs to loadesmlibrary before executingserverscript.I'm having the same issue on node 4.2.6 with Ubuntu.
@roccomuso can you please try running
node -r esm ./bin/serveras well and let us know if it's working that way?@siburny No it's not working.
The only thing that worked for me (node 8) was to remove the shebang and put
node -r esm ./bin/serverinside thepackage.jsonas "start" shortcut.@siburny
node -r esm ./bin/serverworks good on centos 7Maybe this can help : https://github.com/standard-things/esm it's a polyfill for older versions of node
I believe it's something highly pm2-specific, because I overcame this just by restarting/updating pm2:
pm2 update. First I've added"node_args" : "-r esm"to my config file, but this also haven't worked out although I began to get another error. And only after restarting pm2 localtunnel started to work.It may look silly, but judging by this pm2 issue pm2 may have some problem.
Anyway I've solved this problem without updating any of pm2 files, but just by changing pm2 config and restart
@arthot thanks, it did work for me.
All the solutions above doesn't help me.
I'm really not an expert in this stuff, but I got an other solution.
I wrote a small script:
#!/bin/bashcd <yourpath>/localtunnel-servernode -r esm ./bin/server --port 1234Of course
<yourpath>must be adapted to your installation.Starting the server with this script works fine for me.
Also starting this script with pm2 works for me.
This is what worked for me. I had to change/add 'exec_interpreter' in my pm2.config.json file with value 'bash'. Also, for you to be able to connect to your lt server, you might need to change the above command as below:
#!/bin/bashcd <your-tunnel-server-directory>node -r esm ./bin/server --port <YOUR PORT> --net host --domain <eg, sub.domain.com. Base domain/subdomain where you want your tunnelservert to be hosted>Had the issue with
/usr/bin/env: node -r esm: No such file or directoryand had it solved usingnode -r esm ./bin/serverbut now I'm getting this error with node 14.15.0:Any ideas?
It looks like .json file is corrupt. Can you post it somewhere? Or use online JSON validator.
Update: I am referring to
/root/server/node_modules/localenv/package.jsonfileI took a good look at the file and it seems ok. I used JSON validators and JSON lint, it's all right.
The position mentioned (1492) in the error is the last byte of the file. It's exactly the file length and there is nothing at the end of the file, except for the closing brackets and EOF.
I was able to reproduce this error on the fresh installation. Version of
esmmodule is outdated in package-lock.json. You should upgrade it withnpm install esm@3, and then it will work fine.It works for me by follow
npm install esm@3#!/usr/bin/env node -r esmto#!/usr/bin/env -S node -r esmEnvironment:
Hi there fresh install on ubuntu 20.04 LTS
fixed by @steven11329 recap
Fixed this issue here https://github.com/StyleT/mytunnel-server It now runs on latest Node.js LTS.