Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Cannot find module "/snapshot/auto-pick-system/package.json". #424

Closed
shixukai opened this issue May 22, 2018 · 1 comment
Closed

Cannot find module "/snapshot/auto-pick-system/package.json". #424

shixukai opened this issue May 22, 2018 · 1 comment

Comments

@shixukai
Copy link

shixukai commented May 22, 2018

2018-05-22 10:53:08:923 - error: uncaughtException: Cannot find module "/snapshot/auto-pick-system/package.json". date=Tue May 22 2018 10:53:08 GMT+0800 (CST), pid=25108, uid=501, gid=20, cwd=/Users/douya/Projects/auto-pick-system, execPath=/Users/douya/Projects/auto-pick-system/HuiCang_AutoPick, version=v8.9.0, argv=[/Users/douya/Projects/auto-pick-system/HuiCang_AutoPick, /snapshot/auto-pick-system/bundle.js], rss=143110144, heapTotal=93777920, heapUsed=76532312, external=30870759, loadavg=[3.423828125, 6.72119140625, 4.865234375], uptime=1987487 Error: Cannot find module "/snapshot/auto-pick-system/package.json". at webpackEmptyContext (webpack:///./node_modules/node-pre-gyp/lib_sync?:2:10) at Object.exports.find (webpack:///./node_modules/node-pre-gyp/lib/pre-binding.js?:19:48) at eval (webpack:///./node_modules/bcrypt/bcrypt.js?:5:27) at Object.<anonymous> (/snapshot/auto-pick-system/bundle.js:1:9549139) at t (/snapshot/auto-pick-system/bundle.js:1:172) at eval (webpack:///./backend/models/user.js?:107:15) at Object.<anonymous> (/snapshot/auto-pick-system/bundle.js:1:1754685) at t (/snapshot/auto-pick-system/bundle.js:1:172) at eval (webpack:///./backend/controllers/usersController.js?:140:13) at Object.<anonymous> (/snapshot/auto-pick-system/bundle.js:1:10244536)

I use webpack bundle the server side code.


module.exports = {
  mode: 'production',
  entry: ['./backend/bin/www.js'],
  target: 'node',
  node: {
    __dirname: false,
    __filename: false,
  },
  output: {
    path: path.join(process.cwd(), './'),
    filename: 'bundle.js'
  },
  // externals: [nodeExternals()],
  module: {
    rules: [
      {
        test: /\.(js|jsx)$/,
        use: [
          { loader: 'babel-loader',
            options: {
              babelrc: path.join(process.cwd(), './.babelrc')
            }
          },
          {
            loader: "shebang-loader",
          }
        ],
        exclude: [
          path.join(process.cwd(), './node_modules'),
        ],
        include: [
          path.join(process.cwd(), './backend'),
          path.join(process.cwd(), './config'),
        ]
      },
      {
        test: /\.(js|jsx)$/,
        use: [
          {
            loader: "shebang-loader",
          }
        ],
      }
    ]
  },
  devtool: 'eval'
}

package.json:

"bin": "bundle.js",

then I run:
pkg . -t node8-macos-x64

@hipstersmoothie
Copy link
Contributor

closing in favor of #477

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

No branches or pull requests

2 participants