Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ghost-CLI: npm install sqlite3 --save error #281

Closed
johnathon-b opened this issue Jul 5, 2017 · 27 comments · Fixed by #409
Closed

Ghost-CLI: npm install sqlite3 --save error #281

johnathon-b opened this issue Jul 5, 2017 · 27 comments · Fixed by #409

Comments

@johnathon-b
Copy link

Currently when using ghost-cli 1.0.0.4 and using ghost install local during the installation I get this error and the installation fails.

image

@johnathon-b
Copy link
Author

This was fixed by uninstalling and reinstall of ghost-CLI.

npm un -g ghost-cli && npm i -g ghost-cli

@ErisDS
Copy link
Member

ErisDS commented Jul 8, 2017

For anyone else who comes across this issue, it is caused by changing node versions after installing ghost-cli.

Sqlite3 is a binary dependency that comes with precompiled binaries and downloads the right one for your system on install. If you change the environment, it will look for a different binary, which wasn't downloaded.

Ideally, the CLI would catch this error and explain clearly what the problem was 😬

@ltribolet
Copy link

ltribolet commented Jul 9, 2017

I tried to remove everything (purge nodejs from system and remove all node_modules across system), so this is like a fresh install and I've still got the error.

$ npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm
$ sudo apt-get remove --purge nodejs
$ sudo apt-get install nodejs
$ npm install -g ghost-cli

Ubuntu 16.04
Node v6.11.0

$ ghost install local
✔ Checking for latest Ghost version
✔ Running system checks
✔ Setting up install directory
✔ Downloading and installing Ghost v1.0.0-beta.2
✔ Moving files
✔ Configuring Ghost
ℹ Running setup checks [skipped]
✔ Setting up instance
Knex: run
$ npm install sqlite3 --save
Error: Cannot find module '/usr/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/binding/node-v48-linux-x64/node_sqlite3.node'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.Module._load (module.js:417:25)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/usr/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/sqlite3.js:4:15)
    at Module._compile (module.js:570:32)
    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 Client_SQLite3._driver (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/dialects/sqlite3/index.js:75:12)
    at Client_SQLite3.initializeDriver (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/client.js:219:26)
    at Client_SQLite3.Client (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/client.js:113:10)
    at new Client_SQLite3 (/usr/lib/node_modules/ghost-cli/node_modules/knex/lib/dialects/sqlite3/index.js:58:20)

@ErisDS
Copy link
Member

ErisDS commented Jul 9, 2017

As mentioned by @johnathon-b a workable fix would be npm un -g ghost-cli && npm i -g ghost-cli

@johnathon-b
Copy link
Author

I had this happen on another machine of mine and I went ahead and reinstalled the sqlite3 bits as well during the process.

@ltribolet
Copy link

@ErisDS I've got the same error. What's supposed to do the i option anyway that would fix it ? Because this is the only difference that I spot from what I did earlier.

@ErisDS
Copy link
Member

ErisDS commented Jul 10, 2017

@ltribolet NPM docs: https://docs.npmjs.com/cli/install & https://docs.npmjs.com/cli/uninstall

npm un -g ghost-cli && npm i -g ghost-cli

Uninstalls and then reinstalls the CLI, which is the simplest and most reliable way to refresh the node modules.

Your version:

$ npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm

  • Command that attempts to delete all node modules - if anyone copies this command & uses it on a machine with other node projects installed, they will impact their entire system. Not necessary.

$ sudo apt-get remove --purge nodejs

Removes node, again, unnecessary.

$ sudo apt-get install nodejs

Installed node, but v8.x.x, which is not supported by Ghost. This may also be causing you problems. I recommend following the (still in progress) docs for the CLI on docs.ghost.org (link may change): https://docs.ghost.org/v1.0.0/docs/installing-ghost-via-the-cli#section-install-node-js

$ npm install -g ghost-cli

The same as npm i -g ghost-cli.

@ltribolet
Copy link

Nope I've installed the v6.x.x, I followed the official documentation with the v6 repository after seeing the v8 was not working.

I uninstalled everything in case of another package causing some conflict or maybe I missed something on the way. I know that is not necessary but this way I was sure nothing else was impacting the installation.

So whatever I do I'm stucked with this error :/

@nicolinuxfr
Copy link

nicolinuxfr commented Jul 13, 2017

Same problem here, I tried everything told here and nothing worked.

I’m using Ubuntu 16.04.2 and followed the docs to install nodejs and ghost-cli.

@ErisDS
Copy link
Member

ErisDS commented Jul 17, 2017

I have just run ghost install local on Ubuntu 16.04, setup the way that the docs suggest and it worked ok - however given the number of reports of this issue, there is clearly something screwy going on somewhere.

The error suggests that there is either some mismatch in the node versions between install of ghost-cli and running commands, as I originally thought, or perhaps that the install didn't complete. Anyone experiencing this issue, the information that would be useful to reproduce is:

  • how you installed node
  • how you installed ghost-cli
  • what version of node you were on when you installed ghost-cli
  • what version of node you were on when you ran ghost install local
  • the contents of /usr/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/binding/ (cd into that folder and do ls -al.

Please note: whilst we do want to get to the bottom of this at some point, the primary use cases are ghost install on Ubuntu and ghost install local on Mac and Windows. I'm not 100% on what the use case for using ghost install local on Ubuntu 16.04 is (are you all using Ubuntu as your local machine?) Therefore, this may not be prioritised until after 1.0.0.

cc @acburdine I'm starting to think we may need to output a quick info message at the start of ghost install local saying what node version the CLI sees to help debug these problems?

@scambier
Copy link

scambier commented Jul 17, 2017

I had the same problem (Ubuntu 16.04 bash on Windows), here is how it went:

  • Node 4.x is already installed (managed with nvm)
  • Ghost-cli (older version) is already installed, and I update it to the latest version (with npm)
  • ghost install local failed
  • Uninstalled and reinstalled: still failed
  • Installed latest Node 6.x and ghost-cli over it: now it works

@nicolinuxfr
Copy link

For me, the local installation was to use sqlite3 instead of MySQL. I was experimenting on a live server and I did not want to touch the MySQL databases.

But I understand the idea that it's desktop only.

Here are your answers anyway :

  • I followed the guide
  • Same
  • Node v6.11.1
  • Node v6.11.1
  • Only one folder :  node-v48-linux-x64

@acburdine acburdine added this to the 1.0.1 milestone Jul 23, 2017
@ltribolet
Copy link

ltribolet commented Jul 24, 2017

  • Installed with the official documentation (curl script that added ppa and installed node)
  • Followed documentation on https://docs.ghost.org/docs/installing-ghost-via-the-cli
  • First I was on node v8 but then installed failed so I downgraded to v6 still following official documentation
  • node v6.11.1
ls -la /usr/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/binding/
ls: cannot access '/usr/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/binding/': No such file or directory

I onl y got this

ls -la /usr/lib/node_modules/ghost-cli/node_modules/sqlite3/
total 88
drwxr-xr-x   6 luc    luc     4096 Jul  5 22:13 .
drwxr-xr-x 447 root   root   20480 Jul  5 22:13 ..
-rw-r--r--   1 luc    luc     1817 Oct 27  2016 appveyor.yml
-rw-r--r--   1 luc    luc     1408 Nov  2  2015 binding.gyp
-rw-r--r--   1 luc    luc     5178 Oct 27  2016 CHANGELOG.md
-rw-r--r--   1 luc    luc     2815 Mar 21  2016 CONTRIBUTING.md
drwxr-xr-x   2 luc    luc     4096 Jul  5 22:13 deps
-rw-r--r--   1 luc    luc      281 Oct 27  2016 .eslintrc.js
drwxr-xr-x   2 luc    luc     4096 Jul  5 22:13 lib
-rw-r--r--   1 luc    luc     1460 Feb 12  2014 LICENSE
drwxr-xr-x   5 root   root    4096 Jul  5 22:13 node_modules
-rw-r--r--   1 luc    luc     3249 Jul  5 22:13 package.json
-rw-r--r--   1 luc    luc     8383 Sep 13  2016 README.md
-rw-r--r--   1 luc    luc       43 Feb 12  2014 sqlite3.js
drwxr-xr-x   2 luc    luc     4096 Jul  5 22:13 src

I'm using sqlite because I just followed the documentation with the local directive. When I tried anyway now I see it has been modified.

@acburdine
Copy link
Member

@ltribolet you will need to re-install Ghost-CLI after downgrading Node versions (npm un -g ghost-cli && npm cache clean && npm i -g ghost-cli). Because sqlite has a native dependency, downgrading node versions will mess up which compiled sqlite version is used, thus requiring a re-install.

@ltribolet
Copy link

Yeah I did that many times since (especially with message from this issue), problem still persists.

@kevingil
Copy link

kevingil commented Jul 24, 2017

I''m installing Ghost in a fresh machine. I'm having the same issue and can't start Ghost. Will there be an update for this? I already tried all the suggested fixes but no luck :(

@johnathon-b
Copy link
Author

@kevingil which OS were you using?

@ErisDS
Copy link
Member

ErisDS commented Jul 25, 2017

@kevingil please read this comment and supply all of the information asked for.

We have not yet been able to establish a reproduction case for this issue, and without a reproduction case it's pretty impossible to know what the fix is. Chances are there is some conflicting node versions installed.

Also to reiterate ghost install local on an ubuntu server is not considered a primary use case, so I am very interested to understand why this is being used.

The more info you provide when reporting issues - including use cases, setups and exact commands, the easier it will be for us to tailor the tools so that they work for you.

@MaximusMcCann
Copy link

MaximusMcCann commented Jul 27, 2017

On a mac, same issue as above. I've unistalled and re-installed ghost many times. Switched from node v6.9.5 to v6.11.1 as well. I do see a brief popup (but disappears immediately) asking if I want to allow sqlite (I believe) network access or something (too quick to read). That's when I see it spit out all the red text.

@ErisDS
Copy link
Member

ErisDS commented Jul 27, 2017

@MaximusMcCann Please read the above comment, and the one before, and post full information.

@MaximusMcCann
Copy link

how you installed node:
--I use nvm
how you installed ghost-cli:
--I used npm un -g ghost-cli && npm i -g ghost-cli & also tried apending @latest in the install portion
what version of node you were on when you installed ghost-cli:
--I've tried with 6.9.5 & 6.11.1
what version of node you were on when you ran ghost install local:
--I've tried with 6.9.5 & 6.11.1
the contents of /usr/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/binding/ (cd into that folder and do ls -al.:
--There is no /usr/lib/node_modules on my computer (Mac osx 10.12.6)
--However at /usr/local/lib/node_modules/ghost-cli/node_modules/sqlite3/lib/binding/

drwxr-xr-x  3 username  admin  102 Jul  8 14:33 .
drwxr-xr-x  6 username  admin  204 Jul  8 14:33 ..
drwxr-xr-x  3 username  admin  102 Jul  8 14:33 node-v51-darwin-x64

FOUND THE ISSUE. was with nvm.

An old version of ghost was trumping over the nvm managed one. I noticed nvm was installing to here /Users/username/.nvm/versions/node/v6.11.1/lib/node_modules/ghost-cli, but the above showed it was still present from a prior non nvm installed version. Therefore, uninstalling wasn't removing the underlying incorrect version.
Steps to fix:
rm -rf /usr/local/lib/node_modules/ghost-cli //careful, am using -f here
node --version //verify it's a proper one
nvm use v6.11.1 //if needed (or a similar version: https://docs.ghost.org/docs/supported-node-versions)
npm un -g ghost-cli && npm i -g ghost-cli // Clean install
ghost install local
and voila

✔ Checking system Node.js version
✔ Checking current folder permissions
ℹ Checking operating system [skipped]
ℹ Checking MySQL is installed [skipped]
✔ Checking for latest Ghost version
✔ Setting up install directory
✔ Downloading and installing Ghost v1.0.2
✔ Finishing install process
✔ Configuring Ghost
✔ Setting up instance
✔ Running database migrations
✔ Validating config
✔ Starting Ghost
You can access your blog at http://localhost:2368/

Ghost uses direct mail by default
To set up an alternative email method read our docs at https://docs.ghost.org/docs/mail-config

@ErisDS
Copy link
Member

ErisDS commented Jul 27, 2017

There is a section about nvm in pr install guide, but I think I'll move this out to the troubleshooting guide and reference the section instead.

TL;DR using nvm doesn't work with ghost-cli unless you set it up specially to be system wide.

In the process of tracking this down and getting to the bottom of it ready to A) improve the docs and B) add some more checks to Ghost doctor

Updated TL;DR is, nvm doesn't work with ghost-cli if it gets installed in root, or the ~/.nvm folder doesn't have enough permissions. Installing Node.js with both nvm and a package manager on the same server can result in multiple versions of node being available, and conflicting. Especially if ghost-cli gets installed somewhere in the middle - we're working on a robust way to resolve this.

@ErisDS
Copy link
Member

ErisDS commented Jul 27, 2017

If you are running into this issue, some things to check would be:

  • If you have a /root/.nvm folder, you need to uninstall nvm, remove this folder and either reinstall nvm as a non-root user, or use the method listed here: https://docs.ghost.org/docs/install#section-install-node-js
  • If you're using nvm as a non root user, ~/.nvm needs 775 permissions
  • The result of which ghost should be inside of npm root -g.

@acburdine acburdine modified the milestones: 1.1.0, 1.0.1 Jul 28, 2017
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jul 31, 2017
refs TryGhost#281
- add better error message when sqlite install hasn't worked
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jul 31, 2017
refs TryGhost#281
- add better error message when sqlite install hasn't worked
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jul 31, 2017
refs TryGhost#281
- add better error message when sqlite install hasn't worked
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jul 31, 2017
closes TryGhost#281
- skip directory check if `--no-setup-linux-user` option is passed
- throw error if npm bin directory is not the same as the one used to install ghost-cli
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Jul 31, 2017
refs TryGhost#281
- add better error message when sqlite install hasn't worked
acburdine added a commit that referenced this issue Jul 31, 2017
refs #281
- add better error message when sqlite install hasn't worked
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Aug 3, 2017
closes TryGhost#281
- throw error if npm bin directory is not the same as the one used to install ghost-cli
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Aug 3, 2017
closes TryGhost#281
- throw error if npm bin directory is not the same as the one used to install ghost-cli
acburdine added a commit to acburdine/Ghost-CLI that referenced this issue Aug 4, 2017
closes TryGhost#281
- throw error if npm bin directory is not the same as the one used to install ghost-cli
acburdine added a commit that referenced this issue Aug 5, 2017
closes #281
- throw error if npm bin directory is not the same as the one used to install ghost-cli
@xih
Copy link

xih commented Dec 15, 2017

Hi,

I've been stuck on this issue for a while now.
ghost --version Ghost-CLI version: 1.4.1 Ghost Version (at ~/Desktop/ghost/theme): 1.19.0

which ghost /usr/local/bin/ghost

npm root -g /usr/local/lib/node_modules

node --version v6.12.2

npm --version 5.6.0

I've tried using nvm, but then it gave me the same error or Error occurred running command: 'yarn install --no-emoji --no-progress' aka out of memory exception.

so then I brew install node@6 and do
npm un -g ghost-cli && npm i -g ghost-cli

but then I get the same error: npm install sqlite3 --save error

I understand that the result of which ghost should be inside of npm root -g, but I have no idea how to make this possible. I've read this page multiple times and tried every command also.

Any suggestions ? Much thanks !!

@UmutAlihan
Copy link

making sure that the correct version (altered by nvm use ..* command) node binary file is executed helped me to solve the issue

thank you!

@ravinaNG
Copy link

I also got the same error but the way you got is different, I am new in MySQL and node.js, so I am not able to find why this error appears.
Can anyone help me to find out the error, please?
To understand the error you can visit here

@lpar
Copy link

lpar commented Nov 15, 2020

Got the same error when using Node 14 LTS (Fedora 33, Yarn). Downgrading to Node 12 LTS and removing and reinstalling ghost-cli fixed it. (yarn global remove ghost-cli && yarn global add ghost-cli)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

13 participants