Joplin: fresh install unexpected identifier

Created on 30 Nov 2017  路  25Comments  路  Source: laurent22/joplin

joplin
/home/user/.nvm/versions/node/v6.10.3/lib/node_modules/joplin/app.js:47
async guessTypeAndLoadItem(pattern, options = null) {
^^^^^^^^^^^^^^^^^^^^
SyntaxError: Unexpected identifier
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (/home/user/.nvm/versions/node/v6.10.3/lib/node_modules/joplin/main.js:7:17)

bug

All 25 comments

It's necessary node 8.7.0 or later.

I had the unexpected identifier issue above and then updated node to v9.2.0 and now I get a module not found error:

module.js:544
throw err;
^

Error: Cannot find module '/usr/local/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v59-darwin-x64/node_sqlite3.node'
at Function.Module._resolveFilename (module.js:542:15)
at Function.Module._load (module.js:472:25)
at Module.require (module.js:585:17)
at require (internal/module.js:11:18)
at Object. (/usr/local/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:641:30)
at Object.Module._extensions..js (module.js:652:10)
at Module.load (module.js:560:32)
at tryModuleLoad (module.js:503:12)
at Function.Module._load (module.js:495:3)

I repeat the above steps (node update from 6.2.0 to 9.2.0) and I get a similar error to the above
$ joplin module.js:544 throw err; ^ Error: Cannot find module '/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/binding/node-v59-linux-x64/node_sqlite3.node' at Function.Module._resolveFilename (module.js:542:15) at Function.Module._load (module.js:472:25) at Module.require (module.js:585:17) at require (internal/module.js:11:18) at Object.<anonymous> (/usr/lib/node_modules/joplin/node_modules/sqlite3/lib/sqlite3.js:4:15) at Module._compile (module.js:641:30) at Object.Module._extensions..js (module.js:652:10) at Module.load (module.js:560:32) at tryModuleLoad (module.js:503:12) at Function.Module._load (module.js:495:3)

I am on an Ubuntu 16.04 64 bit system and tried installing joplin using npm install -g joplin

For various reasons I'm stuck on node 6.x on this machine. It should fail to install if the version of node is too out of date.

I was going to submit a PR on package.json to specify node engine version, but there is no package.json file..?

See also #26

package.json for the node app is under /CliClient - https://github.com/laurent22/joplin/blob/master/CliClient/package.json

I've actually already specified it but somehow it doesn't seem to pick it up, or maybe I didn't get the syntax right? Any idea?

Weird. I'm trying with node 6.12.0 (to see it fail) but it actually installed. Ah, npm doesn't complain, but yarn responds with an error about supported node version, expecting >= 8.7.0.

So npm is just being sloppy.

@krall12, @lordlabakdas, did you install the app with or without sudo? And what is your current npm prefix (can be displayed with npm config get prefix)? Npm unfortunately doesn't provide very good defaults (except via Homebrew on macOS), which sometimes lead to this kind of obscure error messages.

Maybe consider setting your prefix to a directory under your home dir as this seems to cause less problems. Please see option 2 there - https://docs.npmjs.com/getting-started/fixing-npm-permissions

updated as instructed to node v8.9.1, uninstalled joplin, installed from scratch, ran again, same error

@astropanic, did you try moving your global npm dir under $HOME as described in Option 2 there? https://docs.npmjs.com/getting-started/fixing-npm-permissions

@laurent22 I have no permission errors at all.

Just to be sure, is that the same error as above with missing node_sqlite3.node module? Could you let me know if you've installed the app with or without sudo, and what is your npm prefix (with npm config get prefix)?

@laurent22, nope, it's about the first message in this bug report, as I got redirected here from #47

'/usr/local'

@laurent22 , I had installed the app using sudo and npm config get prefix returned /usr/local. Following instructions to change global npm dir under $HOME worked for me (option 2 of https://docs.npmjs.com/getting-started/fixing-npm-permissions).

@lordlabakdas , I don't have to use sudo, and changing some npm options just for one node tool is not really a solution for me, even if that change is necessary, it should be pointed out in an error message, instead of displaying a stacktrace.

Yes I agree, these meaningless stacktraces when something is not setup properly aren't great. If you don't need sudo, I assume /usr/local is owned by yourself? Just trying to understand how it happens so that I can either fix it or display a proper error message.

@astropanic, without changing the default prefix, does it work if you set the permissions as suggested on the npm article?

sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

@laurent22, my permissions are fine, I don't have to fix anything (besides the outdated node version, what I already did). A better solution would be understand from where the error comes and fix that in the first place instead of fiddkling around with the node installation itself hoping for the best.

The thing is npm permissions are not setup properly by default, especially when upgrading from an earlier version. Homebrew set it up properly but on Linux and Windows it needs to be done manually. However I'm going to check if it can simply be installed in a local directory (with the -g flag) and provide a script to do that.

I have now updated the installation instructions to this:

NPM_CONFIG_PREFIX=~/.joplin-bin npm install -g joplin
sudo ln -s ~/.joplin-bin/bin/joplin /usr/bin/joplin

This fixed the installation problems I was having, thank you!

Installing nodejs v8 on Ubuntu 17.10 with this method worked for me:

http://nodesource.com/blog/installing-node-js-8-tutorial-linux-via-package-manager/

@bufferovercat Thanks a lot! Version with NPM_CONFIG_PREFIX=~/.joplin-bin did not work for me for both PC with Linux on board :)

I will close this as I think the doc now has the required information to install it. If you're still having any issue though feel free to comment here and I'll reopen.

For what it's worth.... I encountered this with my Ubuntu 16.04 system with node v8.9.2 installed via nvm.

The solution was to ensure that I was installing it globally without setting the NPM_CONFIG_PREFIX variable. That seems to have installed it with the rest of my globally-installed packages and enabled it to properly resolve the SQLite module.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seagoj picture seagoj  路  3Comments

LifeIsAParadox picture LifeIsAParadox  路  3Comments

Rahulm2310 picture Rahulm2310  路  3Comments

christianlupus picture christianlupus  路  3Comments

jmcastagnetto picture jmcastagnetto  路  3Comments