Giter Club home page Giter Club logo

Comments (15)

essivision avatar essivision commented on July 19, 2024 12

I have same problem and solve it

"bin":"./index.js",
  "pkg": {
    "assets": "./node_modules/figlet/fonts/Standard.flf"
  }

and after that run:

pkg package.json

finally create another .exe file with directory name

from pkg.

igorklopov avatar igorklopov commented on July 19, 2024 3

Seems the problem is that you run pkg app.js. Currently pkg does not know about package.json, because you specify app.js directly.

Instead you should add app.js as bin entry in package.json. And then run pkg package.json or simply pkg .

from pkg.

igorklopov avatar igorklopov commented on July 19, 2024

Please post your code.

from pkg.

ganeshkbhat avatar ganeshkbhat commented on July 19, 2024

Here is the code. Simple express server:

var express = require('express');
var app = express();
var server = require('http').Server(app);
//var io = require('socket.io')(server);

server.listen(8888);

app.use('/lib', express.static('lib'));
app.use(function (req, res, next) {
    res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8888');
    res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
    res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
    res.setHeader('Access-Control-Allow-Credentials', false);
    next();
});
app.get('/', function (req, res) {
  res.sendFile(__dirname + '/views/index.html');
});


If I include socket.io it gives an error related to declaration of this.wsEngine and require(this.wsEngine) in the index.js does not resolve the issue. Is there an example of how I can include this?

from pkg.

igorklopov avatar igorklopov commented on July 19, 2024

I tried but failed to reproduce. Can you make a repo?

from pkg.

ganeshkbhat avatar ganeshkbhat commented on July 19, 2024

app.zip

Please find files attached. Its a simple starter.

from pkg.

igorklopov avatar igorklopov commented on July 19, 2024

I added your code as an example for pkg. Thanks!
Please look at https://github.com/zeit/pkg/blob/master/examples/express/index.js#L9
You should use __dirname explicitly for serve-static root.

from pkg.

ganeshkbhat avatar ganeshkbhat commented on July 19, 2024

@igorklopov socket.io it gives an error related to declaration of this.wsEngine. How would I resolve that by explicit declarations? Any code examples?

from pkg.

ganeshkbhat avatar ganeshkbhat commented on July 19, 2024

@igorklopov any help is welcome :-)

from pkg.

Koka5 avatar Koka5 commented on July 19, 2024

i am also facing the same issue.. any solution ?

So what should i do?

What i have tried,

i just cloned the repo,,

cd examples/express
npm install
node index.js //works great
pkg . 
./index-macos // does not work says views was not included in compilation stage
pkg package.json
./index-macos //  does not work..  again same issue
pkg index.js
./index-macos //  does not work..  again same issue

Please note, i have not changed a single character in the example.

last line of this comment says "You should use __dirname explicitly for serve-static root."

at line 9 its written :
"__dirname is used here along with package.json.pkg.assets"

now next one is more confusing..
as in the documentation last line of section says that "This way you may even avoid creating pkg config for your project."

So even when the assets is included, nothing works..

May i am doing some silly mistake, please help me out.

from pkg.

Judgemenot avatar Judgemenot commented on July 19, 2024

T grotto

from pkg.

Koka5 avatar Koka5 commented on July 19, 2024

it was a silly mistake.. Just forget it.. it got it working..

from pkg.

uullrich avatar uullrich commented on July 19, 2024

Could you please tell me the reason / solution for your mistake?

from pkg.

Koka5 avatar Koka5 commented on July 19, 2024

@uullrich in the package.json i had not mentioned the "bin" property

from pkg.

nathanmfast avatar nathanmfast commented on July 19, 2024

@essivision Thanks! That's exactly what I needed.

from pkg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.