realm / realm-object-server

Tracking of issues related to the Realm Object Server and other general issues not related to the specific SDK's
https://realm.io
293 stars 42 forks source link

Error when running ROS - node_modules/.bin/tsc: No such file or directory #317

Closed ozmaat closed 6 years ago

ozmaat commented 6 years ago

I was not able to run ROS after installing it.

Goals

Install ROS on CentOS Linux 7.4 and start ROS with npm start

Expected Results

After the command"ros init my-app" , "npm start" would run ROS

Actual Results

I get the following error after running "npm start"

`my-ros-app@1.0.0 start /home/user1/realmapp

npm run build && node dist/index.js

my-ros-app@1.0.0 build /home/user1/realmapp rm -rf dist; ./node_modules/.bin/tsc

sh: ./node_modules/.bin/tsc: No such file or directory npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! my-ros-app@1.0.0 build: rm -rf dist; ./node_modules/.bin/tsc npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the my-ros-app@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/user1/.npm/_logs/2017-12-13T15_28_45_808Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-ros-app@1.0.0 start: npm run build && node dist/index.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the my-ros-app@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/user1/.npm/_logs/2017-12-13T15_28_45_824Z-debug.log`

Steps to Reproduce

Also tried installing with npm "install -g realm-object-server"

I don't get any error but an "undefined" is added at the end of line as below after the command runs.

"Installing dependencies... A little patience is good.undefined"

Version of Realm and Tooling

Logs

systemctl status realm-object-server.service Dec 13 11:14:22 dom systemd[1]: Started Realm Object Server. Dec 13 11:14:22 dom systemd[1]: Starting Realm Object Server... Dec 13 11:14:23 dom realm-object-server[26823]: read configuration from /etc/realm/configuration.yml. Dec 13 12:09:48 dom systemd[1]: Stopping Realm Object Server... Dec 13 12:09:48 dom systemd[1]: Stopped Realm Object Server. Warning: realm-object-server.service changed on disk. Run 'systemctl daemon-reload' to reload units.
sudo journalctl -u realm-object-server.service Dec 13 11:14:22 dom systemd[1]: Started Realm Object Server. Dec 13 11:14:22 dom systemd[1]: Starting Realm Object Server... Dec 13 11:14:23 dom realm-object-server[26823]: read configuration from /etc/realm/configuration.yml. Dec 13 12:09:48 dom systemd[1]: Stopping Realm Object Server... Dec 13 12:09:48 dom systemd[1]: Stopped Realm Object Server.
cat /var/log/realm-object-server.log No log after running the neither ros-init or npm start

Attaching logs from npm/logs after the running - npm start log2.txt log1.txt

Thank you

JimDuskes commented 6 years ago

Same here. ROS 2.2.0 won’t start on CentOS 7

I’ve followed the installation instructions on the Realm website many times with no luck. I’m installing it on a Linode.com CentOS 7 VM.

Using 'npm start’ in my app’s folder, outputs the following: (formatting, such as partial crossing out of lines, was added by github)

my-ros-app@1.0.0 start /home/tony/BOTH npm run build && node dist/index.js "BOTH"

my-ros-app@1.0.0 build /home/tony/BOTH rm -rf dist; ./node_modules/.bin/tsc

sh: ./node_modules/.bin/tsc: No such file or directory npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! my-ros-app@1.0.0 build: rm -rf dist; ./node_modules/.bin/tsc npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the my-ros-app@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/tony/.npm/_logs/2017-12-14T17_37_49_609Z-debug.log npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! my-ros-app@1.0.0 start: npm run build && node dist/index.js "BOTH" npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the my-ros-app@1.0.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/tony/.npm/_logs/2017-12-14T17_37_49_631Z-debug.log

This is the content of /home/tony/.npm/_logs/2017-12-14T17_37_49_609Z-debug.log

0 info it worked if it ends with ok 1 verbose cli [ '/home/tony/.nvm/versions/node/v8.9.3/bin/node', 1 verbose cli '/home/tony/.nvm/versions/node/v8.9.3/bin/npm', 1 verbose cli 'run', 1 verbose cli 'build' ] 2 info using npm@5.6.0 3 info using node@v8.9.3 4 verbose run-script [ 'prebuild', 'build', 'postbuild' ] 5 info lifecycle my-ros-app@1.0.0~prebuild: my-ros-app@1.0.0 6 info lifecycle my-ros-app@1.0.0~build: my-ros-app@1.0.0 7 verbose lifecycle my-ros-app@1.0.0~build: unsafe-perm in lifecycle true 8 verbose lifecycle my-ros-app@1.0.0~build: PATH: /home/tony/.nvm/versions/node/v8.9.3/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/tony/BOT$ 9 verbose lifecycle my-ros-app@1.0.0~build: CWD: /home/tony/BOTH 10 silly lifecycle my-ros-app@1.0.0~build: Args: [ '-c', 'rm -rf dist; ./node_modules/.bin/tsc' ] 11 info lifecycle my-ros-app@1.0.0~build: Failed to exec build script 12 verbose stack Error: my-ros-app@1.0.0 build: rm -rf dist; ./node_modules/.bin/tsc 12 verbose stack spawn ENOENT 12 verbose stack at ChildProcess. (/home/tony/.nvm/versions/node/v8.9.3/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18) 12 verbose stack at emitTwo (events.js:126:13) 12 verbose stack at ChildProcess.emit (events.js:214:7) 12 verbose stack at maybeClose (internal/child_process.js:925:16) 12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 13 verbose pkgid my-ros-app@1.0.0 14 verbose cwd /home/tony/BOTH 15 verbose Linux 4.9.68-x86_64-linode89 16 verbose argv "/home/tony/.nvm/versions/node/v8.9.3/bin/node" "/home/tony/.nvm/versions/node/v8.9.3/bin/npm" "run" "build" 17 verbose node v8.9.3 18 verbose npm v5.6.0 19 error file sh 20 error code ELIFECYCLE 21 error errno ENOENT 22 error syscall spawn 23 error my-ros-app@1.0.0 build: rm -rf dist; ./node_modules/.bin/tsc 23 error spawn ENOENT 24 error Failed at the my-ros-app@1.0.0 build script. 24 error This is probably not a problem with npm. There is likely additional logging output above. 25 verbose exit [ 1, true ]

The is the content of /home/tony/.npm/_logs/2017-12-14T17_37_49_631Z-debug.log

0 info it worked if it ends with ok 1 verbose cli [ '/home/tony/.nvm/versions/node/v8.9.3/bin/node', 1 verbose cli '/home/tony/.nvm/versions/node/v8.9.3/bin/npm', 1 verbose cli 'start', 1 verbose cli 'BOTH' ] 2 info using npm@5.6.0 3 info using node@v8.9.3 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle my-ros-app@1.0.0~prestart: my-ros-app@1.0.0 6 info lifecycle my-ros-app@1.0.0~start: my-ros-app@1.0.0 7 verbose lifecycle my-ros-app@1.0.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle my-ros-app@1.0.0~start: PATH: /home/tony/.nvm/versions/node/v8.9.3/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/tony/BOT$ 9 verbose lifecycle my-ros-app@1.0.0~start: CWD: /home/tony/BOTH 10 silly lifecycle my-ros-app@1.0.0~start: Args: [ '-c', 'npm run build && node dist/index.js "BOTH"' ] 11 silly lifecycle my-ros-app@1.0.0~start: Returned: code: 1 signal: null 12 info lifecycle my-ros-app@1.0.0~start: Failed to exec start script 13 verbose stack Error: my-ros-app@1.0.0 start: npm run build && node dist/index.js "BOTH" 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (/home/tony/.nvm/versions/node/v8.9.3/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at EventEmitter.emit (events.js:214:7) 13 verbose stack at ChildProcess. (/home/tony/.nvm/versions/node/v8.9.3/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at emitTwo (events.js:126:13) 13 verbose stack at ChildProcess.emit (events.js:214:7) 13 verbose stack at maybeClose (internal/child_process.js:925:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5) 14 verbose pkgid my-ros-app@1.0.0 15 verbose cwd /home/tony/BOTH 16 verbose Linux 4.9.68-x86_64-linode89 17 verbose argv "/home/tony/.nvm/versions/node/v8.9.3/bin/node" "/home/tony/.nvm/versions/node/v8.9.3/bin/npm" "start" "BOTH" 18 verbose node v8.9.3 19 verbose npm v5.6.0 20 error code ELIFECYCLE 21 error errno 1 22 error my-ros-app@1.0.0 start: npm run build && node dist/index.js "BOTH" 22 error Exit status 1 23 error Failed at the my-ros-app@1.0.0 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

After days of trying to get this to work, any help would be appreciated.

bigfish24 commented 6 years ago

Just a guess at the moment but it seems you might not have Typescript installed. Try npm install -g typescript then retry npm start. Also make sure your node modules are up to date by npm install in your project directory that was created from ros init.

ozmaat commented 6 years ago

Tahnks bigfish24. Typescript was not installed globally.

I installed the typescript, and run the npm install

This time it raised another error.

Error: Cannot find module '/home/admuser/realmtest/node_modules/realm-object-server/node_modules/realm/compiled/node-v57_linux_x64/realm.node' at Function.Module._resolveFilename (module.js:536:15) at Function.Module._load (module.js:466:25) at Module.require (module.js:579:17) at require (internal/module.js:11:18) at Object.<anonymous> (/home/admuser/realmtest/node_modules/realm-object-server/node_modules/realm/lib/index.js:102:28) at Module._compile (module.js:635:30) at Object.Module._extensions..js (module.js:646:10) at Module.load (module.js:554:32) at tryModuleLoad (module.js:497:12) at Function.Module._load (module.js:489:3)

Instead of node-v57_linux_x64, current directory structure is as "realm/compiled/node-v48_linux_x64" directory.

I was getting this same error before when I run the

pm2 start /home/admuser/realmtest/src/index.ts

But this time error was as follow:

Error: Cannot find module '/home/admin/realmtest/node_modules/realm/compiled/node-v48_linux_x64/realm.node' Existing directory was "realm/compiled/node-v57_linux_x64".

I have deleted the complete ros directory (realmtest), and run the "ros init realmtest" once more, it returned back to the original error

no such file and directory ... /node_modules/.bin/tsc

For anyone else experiencing a similar issue with typescript init, js init worked without any problem for me.

ros init MyServer --template js

bigfish24 commented 6 years ago

That error means realm-js was not installed correctly. Running npm install realm in the project directory from ros init should solve it. Not sure why it failed to install properly. We created an automatic install script to help with these issues: https://realm.io/docs/realm-object-server/latest#install-realm-object-server but perhaps it is still leaky in unique circumstances.

raudabaugh commented 6 years ago

I had the same issue and was able to solve it by deleting node_modules in the project directory and then running npm install.

ozmaat commented 6 years ago

I used the automatic install. If we run the npm install realm, a different error is thrown.

npm ERR! path /home/admuser/realmtest/node_modules/realm-object-server/node_modules/abbrev
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/home/admuser/realmtest/node_modules/realm-object-server/node_modules/abbrev' -> '/home/admuser/realmtest/node_modules/realm-object-server/node_modules/.abbrev.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

@raudabaugh, I have also tested your suggestion, deleted the node_modules directory, and run npm install.

The previous errors are gone and npm start do work this time. But runningpm2 start /home/admuser/realmtest/src/index.ts, it causes the error below.

 | Error: Cannot find module '/home/admuser/realmtest/node_modules/realm/compiled/node-v48_linux_x64/realm.node'
7|index    |     at Function.Module._resolveFilename (module.js:469:15)
7|index    |     at Function.Module._load (module.js:417:25)
7|index    |     at Module.require (module.js:497:17)
7|index    |     at require (internal/module.js:20:19)
7|index    |     at Object.<anonymous> (/home/admuser/realmtest/node_modules/realm/lib/index.js:102:28)
7|index    |     at Module._compile (module.js:570:32)
7|index    |     at Object.Module._extensions..js (module.js:579:10)
7|index    |     at Module.load (module.js:487:32)
7|index    |     at tryModuleLoad (module.js:446:12)
7|index    |     at Function.Module._load (module.js:438:3)
PM2        | App [index] with id [7] and pid [32375], exited with code [1] via signal [SIGINT]

Existing directory is /home/admuser/realmtest/node_modules/realm/compiled/node-v57_linux_x64 but ROS looks for node-v48_linux_x64.

Can you start the ROS with pm2 without any errors?

ozmaat commented 6 years ago

Using the temporary fix mentioned here by csotiriou had solved the issue for now.

bigfish24 commented 6 years ago

If you run pm2 on the index.ts file directly you need to install Typescript for pm2 as well. Typescript must be compiled, so you either run npm run build to create /dist/index.js from compilation which you can then run directly or you must run pm2 install typescript as described here: https://realm.io/docs/realm-object-server/latest#going-into-production

ozmaat commented 6 years ago

Thanks bigfish24 but I have already installed Typescript for pm2. It looks like the above error has not been resolved for ROS yet although the bug's been closed.

bigfish24 commented 6 years ago

ah the error seems to imply your pm2 command is running on a different version of Node than when you ran npm install. The file in node_module/realm/compiled are native compiled binaries and thus are built specific for the version of Node. When you run npm install realm it downloads the binary for the version you have.

This can run into problems if you use nvm since you can have multiple node versions installed, which is what appears to be the case. Is that true?

ozmaat commented 6 years ago

pm2 is installed with root user, and the node version is 6.12.0

ROS is installed with a normal user, and the result of the nvm ls is

->       v8.9.3
         system
default -> lts/* (-> v8.9.3)
node -> stable (-> v8.9.3) (default)
stable -> 8.9 (-> v8.9.3) (default)
iojs -> N/A (default)
lts/* -> lts/carbon (-> v8.9.3)
lts/argon -> v4.8.7 (-> N/A)
lts/boron -> v6.12.2 (-> N/A)
lts/carbon -> v8.9.3

I am new to node environment. do we need to install pm2 for the regular user in this case, so that they will use the same node version?

bigfish24 commented 6 years ago

Yes that is the issue. The native module for 6 is different than 8 and is why you see the error.

ozmaat commented 6 years ago

I have installed a local pm2 under the ros project, and the ROS starts without any problem. Although the temporary fix did work, it was not consistent somehow, and couldn't find why sometimes works and sometimes not.

Thanks bigfish24.

JimDuskes commented 6 years ago

My problem was solved by using raudabaugh's suggestion. Thank you!

The serevr now starts but is unreachable from Realm Studio.

This is the output:

npm start

my-ros-app@1.0.0 start /home/tony/BOTH npm run build && node dist/index.js

my-ros-app@1.0.0 build /home/tony/BOTH rm -rf dist; ./node_modules/.bin/tsc

info: Loaded feature token capabilities=[Sync], expires=Wed Apr 19 2017 10:15:29 GMT-0400 (EDT) info: Realm Object Server version 2.2.0 is starting info: [sync] Realm sync server started ([realm-core-4.0.4], [realm-sync-2.1.8]) info: [sync] Directory holding persistent state: /home/tony/BOTH/data/sync/user_data info: [sync] Operating mode: master_with_no_slave info: [sync] Log level: info info: [sync] Download log compaction is enabled info: [sync] Max download size: 131072 bytes info: [sync] Listening on 127.0.0.1:38351 (sync protocol version 22) info: Autocreated admin token user: admin warn: TokenValidator couldn't check if token was revoked: The TokenRevocationRealm wasn't opened. warn: TokenValidator couldn't check if token was revoked: The TokenRevocationRealm wasn't opened. info: [http] 127.0.0.1 - GET /realms/files/%2Fwildcardpermissions HTTP/1.1 200 55 - 22.095 ms info: [http] 127.0.0.1 - GET /realms/files/%2Fpassword HTTP/1.1 200 44 - 44.422 ms warn: TokenValidator couldn't check if token was revoked: The TokenRevocationRealm wasn't opened. info: [http] 127.0.0.1 - GET /realms/files/%2Fperm HTTP/1.1 200 40 - 13.212 ms warn: TokenValidator couldn't check if token was revoked: The TokenRevocationRealm wasn't opened. info: [http] 127.0.0.1 - GET /realms/files/%2Fadmin HTTP/1.1 200 41 - 6.298 ms warn: TokenValidator couldn't check if token was revoked: The TokenRevocationRealm wasn't opened. info: [http] 127.0.0.1 - GET /realms/files/%2Fadmin HTTP/1.1 200 41 - 7.909 ms info: Autocreated admin user: realm-admin info: Realm Object Server has started and is listening on http://0.0.0.0:9080 Realm Object Server was started on 0.0.0.0:9080

JimDuskes commented 6 years ago

Success!

Ran the following from the Realm troubleshooting page to open Port 9080 on the firewall and all is well.

sudo firewall-cmd --get-active-zones sudo firewall-cmd --zone=public --add-port=9080/tcp --permanent sudo firewall-cmd --reload

Many thanks!

codegrue commented 6 years ago

Installation onto fresh Ubuntu image with these steps:

curl -s https://raw.githubusercontent.com/realm/realm-object-server/master/install.sh | bash export NVM_DIR="/home/realmadmin/.nvm" . "/home/realmadmin/.nvm/nvm.sh" # This loads nvm nvm use v8.9.4 ros init myapp cd myapp npm start

This error results:

rm -rf dist; ./node_modules/.bin/tsc

sh: 1: ./node_modules/.bin/tsc: not found npm ERR! file sh npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn npm ERR! my-ros-app@1.0.0 build: rm -rf dist; ./node_modules/.bin/tsc npm ERR! spawn ENOENT npm ERR! npm ERR! Failed at the my-ros-app@1.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

Tried this on both Azure and Digital Ocean, same exact behavior.

Update: Tried manual install process instead of the automated script and got the exact same error.

Update 2: deleted entire node_modules folder and ran "npm install". Then "npm start" worked.

revolter commented 6 years ago

Following the steps from this documentation page, I also got this error when running npm start:

> my-ros-app@1.0.0 start /Users/revolt/Development/my-app
> npm run build && node dist/index.js

> my-ros-app@1.0.0 build /Users/revolt/Development/my-app
> rm -rf dist; ./node_modules/.bin/tsc

sh: ./node_modules/.bin/tsc: No such file or directory
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! my-ros-app@1.0.0 build: `rm -rf dist; ./node_modules/.bin/tsc`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the my-ros-app@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/revolt/.npm/_logs/2018-01-13T22_23_44_135Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! my-ros-app@1.0.0 start: `npm run build && node dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the my-ros-app@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/revolt/.npm/_logs/2018-01-13T22_23_44_164Z-debug.log

Running npm install throws this error:

npm WARN my-ros-app@1.0.0 No repository field.
npm WARN my-ros-app@1.0.0 No license field.

npm ERR! path /Users/revolt/Development/my-app/node_modules/realm-object-server/node_modules/abbrev
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/revolt/Development/my-app/node_modules/realm-object-server/node_modules/abbrev' -> '/Users/revolt/Development/my-app/node_modules/realm-object-server/node_modules/.abbrev.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/revolt/.npm/_logs/2018-01-13T22_16_01_290Z-debug.log

Running npm install realm throws the same error as npm install does.

Deleting node_modules and running npm install then npm start again worked.

  1. This issue should not have been closed, and it should be reopened until the onboarding is fixed.
  2. The docs should state that you need to install typescript.
  3. There shouldn't be the need of removing the node_modules folder in order for it to work.
  4. Until this is fixed, the docs could temporarily present this warning to avoid any friction and unnecessary searches.

It should/could look like this:


This creates a Typescript-based Node project for you.

If you don't have typescript installed, you can do this by running:

npm install -g typescript

Later on you can explore customizing it but for now simply start the server with defaults by:

cd my-app
rm -rf node_modules && npm install # this is temporarily needed until the install script is fixed
npm start