Cannot run in production mode

202 Views Asked by At

I have a donejs application and its running ok in development mode donejs develop, but when I run it in production mode:

  1. donejs build
  2. donejs deploy (to firebase)
  3. NODE_ENV=production donejs start

it will not start and show an error (see CODE A)

This file: file:my-app/dist/bundles/my-app/index.js:704 corresponds to JQuery 3.x and its not a dependency of the project itself but a dependency of can-connect-feathers (https://github.com/canjs/can-connect-feathers). In fact in index.js there is also included JQuery 2.x what makes me think there might be some sort of incompatibility among them.

I already tried changing the project's dependency to JQuery 3.x but didn't help. Actually it will make even donejs develop fail (see CODE B).

I also tried the following: cd my-app/node_modules/steal npm install but didn't help, another error appears and finally tried cd my-app/node_modules/can && npm install but that end up in multiple errors.

I'm using:

CODE A

NODE_ENV=production donejs start

[email protected] start my-app done-serve --proxy http://localhost:3030 --port 8080 done-serve starting on http://localhost:8080 Potentially unhandled rejection [5] TypeError: Error loading "package.json!npm" at file:my-app/package.json Error loading "bundles/my-app/index" at file:my-app/dist/bundles/my-app/index.js Error evaluating file:my-app/dist/bundles/my-app/index.js Cannot read property 'createElement' of undefined at i (file:my-app/dist/bundles/my-app/index.js:704:20) at file:my-app/dist/bundles/my-app/index.js:1039:2881 at file:my-app/dist/bundles/my-app/index.js:1039:3580 at file:my-app/dist/bundles/my-app/index.js:268:21 at file:my-app/dist/bundles/my-app/index.js:268:27 at Object.exports.runInThisContext (vm.js:54:17) at doEval (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:2059:10) at __eval (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:1976:7) at Loader.exec [as __exec] (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:339:5) at Loader.loader.instantiate (my-app/node_modules/steal/node_modules/steal-systemjs/dist/system.src.js:1517:16)

CODE B

donejs develop

[email protected] develop my-app done-serve --develop --proxy http://localhost:3030 --port 8080 done-serve starting on http://localhost:8080 Potentially unhandled rejection [8] Error: Error loading "[email protected]#[email protected]#autorender" at <unknown> Error loading "[email protected]#util/jquery/jquery" at file:my-app/node_modules/can/util/jquery/jquery.js Error loading "[email protected]#util/jquery/jquery" from "[email protected]#autorender" at file:my-app/node_modules/done-autorender/src/autorender.js Did not find ./node_modules/can/node_modules/jquery/package.json at FetchTask.utils.extend.next (file:my-app/node_modules/steal/ext/npm-crawl.js:532:11) at file:my-app/node_modules/steal/ext/npm-crawl.js:556:33 at tryCatchReject (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1183:30) at runContinuation1 (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1142:4) at Fulfilled.when (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:930:4) at Pending.run (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:821:13) at Scheduler._drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:97:19) at Scheduler.drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:62:9) at nextTickCallbackWith0Args (node.js:436:9) at process._tickCallback (node.js:365:13) Potentially unhandled rejection [16] Error: Error loading "[email protected]#util/jquery/jquery" at file:my-app/node_modules/can/util/jquery/jquery.js Error loading "[email protected]#util/jquery/jquery" from "[email protected]#[email protected]#autorender" at file:my-app/src/index.stache Did not find ./node_modules/can/node_modules/jquery/package.json at FetchTask.utils.extend.next (file:my-app/node_modules/steal/ext/npm-crawl.js:532:11) at file:my-app/node_modules/steal/ext/npm-crawl.js:556:33 at tryCatchReject (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1183:30) at runContinuation1 (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:1142:4) at Fulfilled.when (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:930:4) at Pending.run (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:821:13) at Scheduler._drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:97:19) at Scheduler.drain (my-app/node_modules/steal/node_modules/steal-systemjs/node_modules/steal-es6-module-loader/dist/es6-module-loader.src.js:62:9) at nextTickCallbackWith0Args (node.js:436:9) at process._tickCallback (node.js:365:13)

1

There are 1 best solutions below

0
On BEST ANSWER

If the double jQuery installation is the issue, it should be resolved by version 2.0.0, which is exactly the same as the 1.0 version, but requires that you pass in a jQuery package as the jquery option. So, in addition to whatever else you had in your can-connect-feathers config, you'll need to provide the jquery option:

import $ from 'jquery'
import Feathers from 'can-connect-feathers';

new Feathers({
  jquery: $
});