shannah / jdeploy

Developer friendly desktop deployment tool
https://www.jdeploy.com
Apache License 2.0
353 stars 19 forks source link

Deployed npm package doesn't seem to run #4

Open zachgrayio opened 7 years ago

zachgrayio commented 7 years ago

I'm able to deploy, and to install the app and run it fine with jdeploy install, however if I install with npm i -g myapp, I get the following when trying to run:

module.js:491
    throw err;
    ^

Error: Cannot find module 'shelljs/global'
    at Function.Module._resolveFilename (module.js:489:15)
    at Function.Module._load (module.js:439:25)
    at Module.require (module.js:517:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/triggerhippy/.npm-packages/lib/node_modules/kalk/jdeploy-bundle/jdeploy.js:82:13)
    at Module._compile (module.js:573:30)
    at Object.Module._extensions..js (module.js:584:10)
    at Module.load (module.js:507:32)
    at tryModuleLoad (module.js:470:12)
    at Function.Module._load (module.js:462:3)
shannah commented 7 years ago

I was looking at your package.json from the the other issue, and there are a couple of red flags. Mainly:

Why do you need to add the kalk-1.0.0 directory to the "files" property? jdeploy should pull everything needed into the jdeploy-bundle directory.

Since this error relates to shelljs, I wonder if your changing the dependency to 0.7.8 has caused this. Perhaps try changing it back to 0.7.5.

zachgrayio commented 7 years ago

Made suggested changes:

{
  "bin": {
    "kalk": "jdeploy-bundle/jdeploy.js"
  },
  "author": "zgray@scal.io",
  "description": "A CLI calculator written in Kotlin.",
  "main": "index.js",
  "preferGlobal": true,
  "repository": "https://github.com/zachgrayio/kalk.git",
  "version": "1.2.4",
  "jdeploy": {
    "jar": "kalk-1.2.0/lib/kalk-1.2.0.jar"
  },
  "dependencies": {
    "shelljs": "0.7.5"
  },
  "license": "ISC",
  "name": "kalk",
  "files": [
    "jdeploy-bundle"
  ],
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  }
}

and I get the same error when installing and running v1.2.4 of the app via NPM.

shannah commented 7 years ago

I just installed your app on my machine with npm install -g kalk, then ran it and it ran ok for me.

What is the node and npm version of the machine you're having trouble with.

zachgrayio commented 7 years ago

Interesting. Maybe I'll try reinstalling Node again. I had installed via Homebrew once and then with the installer the second time since there's known issues when installing via Homebrew, maybe I missed something during cleanup.

I'm on macOS 10.12.6. node v8.4.0 npm v5.3.0

shannah commented 7 years ago

I just tried upgrading node through homebrew. Now my node and npm versions match yours. I'm using macOS 10.12.5 - so pretty close to your version.

I then installed kalk again: sudo npm install -g kalk

Worked fine.

Then ran kalk. Appeared to work fine

Steves-MacBook-Pro:~ shannah$ node -v
v8.4.0
Steves-MacBook-Pro:~ shannah$ npm -v
5.3.0
Steves-MacBook-Pro:~ shannah$ sudo npm install -g kalk
Password:
/usr/local/bin/kalk -> /usr/local/lib/node_modules/kalk/jdeploy-bundle/jdeploy.js
+ kalk@1.2.4
updated 14 packages in 3.144s
Steves-MacBook-Pro:~ shannah$ kalk
Hi! Enter a mathematical expression to be evaluated, or enter a command. Commands:
  /exit
  /history
> 
reflexdemon commented 6 years ago

@zachgrayio I think I have found a workaround to your problem. I am using Linux Mint and had the same problem. All I did was I downgraded my Node Version to the previous stable LTS version of nodejs and that started working fine for me.

Steps that I followed,

  1. Install NVM: https://github.com/creationix/nvm/blob/master/README.md#installation
  2. Install the stable version of nodjs using: nvm install v8.11.1
  3. Install your cli tool: npm i -g <your-app-name>

Please let me know how this goes.