Comments (15)
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.
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.
Please post your code.
from pkg.
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.
I tried but failed to reproduce. Can you make a repo?
from pkg.
Please find files attached. Its a simple starter.
from pkg.
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.
@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.
@igorklopov any help is welcome :-)
from pkg.
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.
T grotto
from pkg.
it was a silly mistake.. Just forget it.. it got it working..
from pkg.
Could you please tell me the reason / solution for your mistake?
from pkg.
@uullrich in the package.json i had not mentioned the "bin" property
from pkg.
@essivision Thanks! That's exactly what I needed.
from pkg.
Related Issues (20)
- Cannot build base binary for FreeBSD
- Latest arm64 macOS binary does not work when built on Ubuntu HOT 2
- there is something evil bug when we start a exe which is created by pkg
- Failed to compile Gluon applications correctly
- Issue #1962 should not be closed
- Not working with selenium-webdriver HOT 2
- Error! No available node version satisfies 'node20' HOT 4
- Deprecated subdependencies (babel, npmcli, ts-evaluator, and w3c-hr-time)
- fs.promises.access doesn't work in /snapshot HOT 2
- Error! Not more than one entry file/directory is expected HOT 1
- pkg can't use execFile correctly HOT 1
- notice pkg has a serious bug when we use child_process exec exec,execFile spawn HOT 1
- cpSync with recurse:true results in ENOENT
- at Pkg.usageError (/Users/usernameee/volta/tools/image/npm/10.2.4/lib/base-command.js:113:26)
- Failed to launch chrome browser from selenium webdriver in exe file HOT 1
- does it supprot termux
- SyntaxError: Invalid or unexpected token HOT 1
- Error: The specified module could not be found (External DLLs)
- [BUG] can't run child_process.fork with string code HOT 1
- Not able to create binaries for axios node package
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pkg.