Hi, when I deploy to now using @now/node or @now/node-server
using pug template
I get this error
01/30 02:37 PM (60s)
{ Error: Cannot find module '../lib/utils.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at /var/task/user/index.js:18981:12
at Array.map (<anonymous>)
at Object.module.exports.exports.__esModule (/var/task/user/index.js:18980:3)
at __webpack_require__ (/var/task/user/index.js:22:30)
at Object.<anonymous> (/var/task/user/index.js:2151:14)
at __webpack_require__ (/var/task/user/index.js:22:30) code: 'MODULE_NOT_FOUND' }
01/30 02:37 PM (60s)
Error while initializing entrypoint: { Error: Cannot find module '../lib/utils.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at /var/task/user/index.js:18981:12
at Array.map (<anonymous>)
at Object.module.exports.exports.__esModule (/var/task/user/index.js:18980:3)
at __webpack_require__ (/var/task/user/index.js:22:30)
at Object.<anonymous> (/var/task/user/index.js:2151:14)
at __webpack_require__ (/var/task/user/index.js:22:30) code: 'MODULE_NOT_FOUND' }
index.js
const app = require('express')()
const { join } = require('path')
app.set('view engine', 'pug')
app.engine('.pug', require('pug'))
app.set('views', join(__dirname, 'views'))
app.get('*', (req, res) => res.render('index'))
app.listen()
This is due to pug requiring uglify-js which can't be bundled with webpack. See this issue https://github.com/pugjs/pug/issues/2889. It's unfortunate...I feel like requiring uglify-js for production is bad.
This is due to pug requiring uglify-js which can't be bundled with webpack. See this issue pugjs/pug#2889. It's unfortunate...I feel like requiring uglify-js for production is bad.
So how to fix it within ncc?
I guess ncc could treat uglify-js as an external package if that's possible 🤷🏻♂️
The same issue happens with mjml in Now 2 which doesn't use uglify-js.
{ Error: Cannot find module '../lib/utils.js'
at Function.webpackEmptyContext [as resolve] (/var/task/user/src/index.ts:296027:9)
at /var/task/user/src/index.ts:295954:58
at Array.map (<anonymous>)
at Object.module.exports.webpackEmptyContext.keys (/var/task/user/src/index.ts:295953:3)
at __webpack_require__ (/var/task/user/src/index.ts:21:30)
at Object.<anonymous> (/var/task/user/src/index.ts:282664:16)
at __webpack_require__ (/var/task/user/src/index.ts:21:30)
at Object.<anonymous> (/var/task/user/src/index.ts:5523:21)
at __webpack_require__ (/var/task/user/src/index.ts:21:30)
at Object.<anonymous> (/var/task/user/src/index.ts:249979:17) code: 'MODULE_NOT_FOUND' }
I believe pug and uglify-js was fixed in #307
Please use the @now/node@canary builder which includes the latest version of ncc.
Most helpful comment
The same issue happens with
mjmlin Now 2 which doesn't use uglify-js.