xbrowsersync / api

Server-side REST API that serves requests from xBrowserSync client apps
GNU General Public License v3.0
796 stars 83 forks source link

Bunyan not found when starting service #63

Closed harleypig closed 3 years ago

harleypig commented 3 years ago

I am on an archlinux system with all packages up to date. Nodejs and MongoDB are installed.

Mongo is configured per your readme and npm install --unsafe-perm has been executed.

When starting the service I get the following:

 $ node dist/api.js
node:internal/modules/cjs/loader:930
  throw err;
  ^

Error: Cannot find module 'bunyan'
Require stack:
- /home/harleypig/projects/xbrowsersync-api/dist/server.js
- /home/harleypig/projects/xbrowsersync-api/dist/api.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:927:15)
    at Function.Module._load (node:internal/modules/cjs/loader:772:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (node:internal/modules/cjs/helpers:93:18)
    at Object.<anonymous> (/home/harleypig/projects/xbrowsersync-api/dist/server.js:26:34)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Module.require (node:internal/modules/cjs/loader:999:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/harleypig/projects/xbrowsersync-api/dist/server.js',
    '/home/harleypig/projects/xbrowsersync-api/dist/api.js'
  ]
}

I get the same message after running npm install bunyan.

nero120 commented 3 years ago

You shouldn't need to run npm install bunyan since bunyan is a dependency of xbrowsersync-api.

Can you run:

> rm -rf node_modules
> npm install --unsafe-perm

After that, does /home/harleypig/projects/xbrowsersync-api/node_modules/bunyan exist? Also what version of node are you running?

harleypig commented 3 years ago
$ node --version
v16.4.1

The node_modules directory does not exist in the repo directory (or any directory in the repo tree) after running npm install --unsafe-perm. Nothing new is installed in /usr/lib/node_modules and the only other places I can find with that directory name are under other projects.

When running npm install --unsafe-perm (from the top level of the repo) hangs at this point for approximately 4 minutes, then erases the output and drops to the prompt with no other output.

[white boxes] \ reify:date-fns: timing reifyNode:node_modules/typescript Completed in 17555ms

This is what the final output looks like (I added the time command to see how long it took): $ time npm install --unsafe-perm

real    3m59.223s
user    3m51.986s
sys     0m24.683s
nero120 commented 3 years ago

Ah ok. Remove loglevel=silent from .npmrc, that should output better logging, then run:

> npm install

(leave off --unsafe-perm)

I think unsafe-perm was needed on linux due to node-sass, but this may have changed so try without.

harleypig commented 3 years ago

Still didn't install anything, but at least I have an error log now. I wasn't able to attach the file. Github doesn't seem to like the raw file (too large?) or tar.xz, tar.gz, gz, or zip files.

Two sections seem to me to be significant. The first includes 1k lines of what look like commands (g++, ln, cp, mv, etc) but no results and the second looks like a related failure.

1905 error path /home/harleypig/projects/xbrowsersync-api/node_modules/node-sass
1906 error command failed
1907 error command sh -c node scripts/build.js
1908 error Building: /usr/bin/node /home/harleypig/projects/xbrowsersync-api/node_modules/node-gyp/bin/node-gyp.js     rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --   libsass_library=
... 1k lines ...
1908 error make: Leaving directory '/home/harleypig/projects/xbrowsersync-api/node_modules/node-sass/build'

and this

1909 error gyp ERR! build error
1909 error gyp ERR! stack Error: `make` failed with exit code: 2
1909 error gyp ERR! stack     at ChildProcess.onExit (/home/harleypig/projects/xbrowsersync-api/node_modules/node-gyp/lib/build.js:194:23)
1909 error gyp ERR! stack     at ChildProcess.emit (node:events:394:28)
1909 error gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
1909 error gyp ERR! System Linux 5.11.10-arch1-1
1909 error gyp ERR! command "/usr/bin/node" "/home/harleypig/projects/xbrowsersync-api/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
1909 error gyp ERR! cwd /home/harleypig/projects/xbrowsersync-api/node_modules/node-sass
1909 error gyp ERR! node -v v16.4.1
1909 error gyp ERR! node-gyp -v v7.1.2
1909 error gyp ERR! not ok
1909 error Build failed with error code: 1
1910 verbose exit 1

I have gyp installed on my system for other reasons. Would that be interfering?

Also, it appears to be using python in there somewhere so, the python version is 3.9.5.

harleypig commented 3 years ago

I just noticed it's claiming to install files into node_modules under the repo, but no such directory exists. I ran the npm install command and watched for the node_modules to show up, which it did almost immediately and disappeared shortly before the end of the run.

harleypig commented 3 years ago

bump

nero120 commented 3 years ago

Not sure what you want me to say, this isn't an xBrowserSync issue, it's a node-sass/npm/environment issue. Perhaps check here?

harleypig commented 3 years ago

I'm not sure how this is an environmental issue.

When I installed (using npm install node-sass) it installs just fine in a work directory.

When I copy the package.json file to an empty directory and run npm install I get the same error.

I'll work on figuring out which combination is causing the issue.

nero120 commented 3 years ago

This isn't xBrowserSync code, it's the node-sass install process that's having the issue:

error command sh -c node scripts/build.js

scripts/build.js is node_modules/node-sass/scripts/build.js. What do you expect me to do about this, I don't look after that project. You need to create an issue in the node-sass repo.