Code Monkey home page Code Monkey logo

next-pkg's Introduction

img

NPM version Build Status Build status Dependabot Standard - JavaScript Style Guide Join the community on Spectrum

Next-Pkg is a package for compiling your Next.js project with pkg. This is how you can deploy your Next.js apps on enviroments without node installed! (And take advantage of all the other pkg features)

Usage

cd my-next-js-project/
npm install --save next-pkg pkg

and add a script to your package.json like this:

{
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start",
    "dist":"next-pkg"
  }
}

then just run npm run dist and you will find on dist folder your next.js binary compiled project.

Contributing

  1. Fork this repository to your own GitHub account and then clone it to your local device
  2. Link the package to the global module directory: npm link
  3. Within the module you want to test your local development instance of next-pkg, just link it to the dependencies: npm link next-pkg. Instead of the default one from npm, node will now use your clone of Next-Pkg!

Credits

Thanks to ZEIT Team for giving us this two amazing tools to make our life easier!

next-pkg's People

Contributors

dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar fmiras avatar fnky avatar greenkeeper[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

next-pkg's Issues

Warn or build project when isn't already built

When installing next-pkg and running the npm run dist which we suggest from the README.md isn't going to work unless the user runs next build we should warn/ask to build the project before compiling with pkg.

Error on server this distDIr

./next-express-bootstrap-boilerplate
/snapshot/frontend/node_modules/next-server/dist/server/next-server.js:271
throw new Error(Could not find a valid build in the '${this.distDir}' directory! Try building your app with 'next build' before starting the server.);

Failed to load next.config.js

after packaging my app and try running it , i run into an error
`- error Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
/snapshot/next-sample/node_modules/next/dist/server/config.js:546
userConfigModule = await import((0, _url.pathToFileURL)(path).href);
^

TypeError: Invalid host defined options
at loadConfig (/snapshot/next-sample/node_modules/next/dist/server/config.js:546:78)
at async Proxy. (/snapshot/next-sample/node_modules/next/dist/server/next.js:260:44)
`
Thing i have tried are:

  • everything works fine when i run in dev mode
  • when i build and 'next start', it also works fine
  • start a new next project - still encounter same error
  • when i remove the next-config.js - it works but then i run into eslint problems

Action required: Greenkeeper could not be activated 🚨

🚨 You need to enable Continuous Integration on all branches of this repository. 🚨

To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.

Since we didn’t receive a CI status on the greenkeeper/initial branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.

If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/.

Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial branch in this repository, and then remove and re-add this repository to the Greenkeeper App’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.

ENOENT: no such file or directory, stat '/home/shintaro/Desktop/projects/github/frontend/node_modules/next-pkg/lib/server.js'

hello...
I'm using this boiler plalate

sudo npm run dist

[email protected] dist /home/shintaro/Desktop/projects/github/frontend
next-pkg

✖ Error copying temporary files: Error: ENOENT: no such file or directory, stat '/home/shintaro/Desktop/projects/github/frontend/node_modules/next-pkg/lib/server.js'
(node:12322) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, stat '/home/shintaro/Desktop/projects/github/frontend/node_modules/next-pkg/lib/server.js'
(node:12322) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:12322) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Version 10 of node.js has been released

Version 10 of Node.js (code name Dubnium) has been released! 🎊

To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:

  • Added the new Node.js version to your .travis.yml

If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.

More information on this issue

Greenkeeper has checked the engines key in any package.json file, the .nvmrc file, and the .travis.yml file, if present.

  • engines was only updated if it defined a single version, not a range.
  • .nvmrc was updated to Node.js 10
  • .travis.yml was only changed if there was a root-level node_js that didn’t already include Node.js 10, such as node or lts/*. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.

For many simpler .travis.yml configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖


FAQ and help

There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.


Your Greenkeeper Bot 🌴

non-standard "scripts" configuration

Hi, my "dev" command doesn't follow the conventional "next" pattern shown in your documentation and instead I run "node server.js". Will next-pkg work with such a setup or is it totally incompatible?

const port = parseInt(process.env.PORT, 10) || 3000
const dev = process.env.NODE_ENV !== 'production'

const { createServer } = require('http')
const { parse } = require('url')
const next = require('next')
const mobxreact = require('mobx-react')
const app = next({ dev })
const handle = app.getRequestHandler()

mobxreact.useStaticRendering(true)

console.log("process.cwd() = " + process.cwd());

app.prepare().then(() => {
  createServer((req, res) => {
    const parsedUrl = parse(req.url, true)
    const { pathname, query = {} } = parsedUrl;
    if(pathname.includes("/static/") || pathname.includes("/_next/")){
      handle(req, res, parsedUrl)
    }else{
      query.path=pathname
      app.render(req, res, '/', query)
    }

  }).listen(port, err => {
    if (err) throw err
    console.log(`> Ready on http://localhost:${port}`)
  })
})
"scripts": {
    "dev": "node server.js",
    "build": "next build",
    "start": "NODE_ENV=production node server.js",
    "dist": "next-pkg"
  },

Failed to load next.config.js

after packaging my app and try running it , i run into an error
`- error Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
/snapshot/next-sample/node_modules/next/dist/server/config.js:546
userConfigModule = await import((0, _url.pathToFileURL)(path).href);
^

TypeError: Invalid host defined options
at loadConfig (/snapshot/next-sample/node_modules/next/dist/server/config.js:546:78)
at async Proxy. (/snapshot/next-sample/node_modules/next/dist/server/next.js:260:44)
`
Thing i have tried are:

  • everything works fine when i run in dev mode
  • when i build and 'next start', it also works fine
  • start a new next project - still encounter same error
  • when i remove the next-config.js - it works but then i run into eslint problems

Make pkg configurable

Next-Pkg should support package.json pkg configuration as same as pkg does (for example, with assets and scripts properties).

  "pkg": {
    "scripts": "build/**/*.js",
    "assets": "views/**/*"
  }

Support usage of custom next.js server

We should support usage of custom next.js server with next-pkg dist script, maybe reading package.json start script so developers don't need to use pkg manually.

Accept pkg cli arguments

Next-Pkg cli package should accepto pkg cli arguments such as --target or --output using the exec exported function:

await exec([ 'app.js', '--target', 'host', '--output', 'app.exe' ])
// do something with app.exe, run, test, upload, deploy, etc

State of the art

Hello folks,

i'm currently trying to deploy an nextjs application to a windows embedded pc. so l would like to have a complete bundled application.
I've got an exe file out with pkg, but if i start it, it closes immediatly without any errors.

I've also tried it with next-pkg, but it wont work either. so is next-pkg still state of the art or is there a other working way?

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.