Ncc: Failed to compile application dependence Typeorm

Created on 29 Jan 2019  路  11Comments  路  Source: vercel/ncc

01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "mongodb" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "mysql2" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "oracledb" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "pg" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "pg-native" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "pg-query-stream" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "redis" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "ioredis" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "sqlite3" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "sql.js" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/platform" attempted to require "mssql" but could not be resolved, assuming external.
01/29 11:50 AM (1h)
ncc: Module directory "/tmp/3005dec1/user/node_modules/typeorm/driver/react-native" attempted to require "react-native-sqlite-storage" but could not be resolved, assuming external.

Most helpful comment

You could pass in -e packageName for every database package you'r not using.

For the entities the easiest fix is to specify them in TypeORM config like:

import { User  } from "./User.entity";

...
TypeOrmModule.forRoot({
    type: 'mysql'
    ...,
    entities: [ User ],
    synchronize: true
  })
...

All 11 comments

Can you show us your package.json? Some more details please?

I will create a repo for this issue.

And I want to know if now.sh supports the use of custom build scripts instead of ncc.
Because I don鈥榯 always want to output a single file.

What is the exact errors message that you are getting here @zhmushan? The paste above includes warnings only, as opposed to any build or execution error.

@guybedford Sorry, I thought it was the wrong caused by these warnings.(as a beginner of now.sh
Now, I find the reason.
ncc output a single file, but TypeORM depends on the files that define the entity.
It caused me to be unable to deploy the app using now,sh.
I pushed the example of deployment failure to repo.
Any solution?

You could pass in -e packageName for every database package you'r not using.

For the entities the easiest fix is to specify them in TypeORM config like:

import { User  } from "./User.entity";

...
TypeOrmModule.forRoot({
    type: 'mysql'
    ...,
    entities: [ User ],
    synchronize: true
  })
...

@dirkdev98 thx

My now.json
{
"version": 2,
"name": "request:page",
"builds": [
{ "src": "/index.js", "use": "
@now
/node", "config": { "maxLambdaSize": "40mb" } }
],
"routes": [
{"src": "/","dest": "/index.js" }
]
}

My index.js

const chrome = require('chrome-aws-lambda');
const puppeteer = require('puppeteer-core');
export default async (req, res) => {

let body = '';
req.on('data', chunk => {
body += chunk.toString();
});
req.on('end', async () => {
console.log('~~1~~')
const browser = await puppeteer.launch({
args: chrome.args,
executablePath: await chrome.executablePath,
headless: chrome.headless,
});
console.log('
~2~')
let page = await browser.newPage();
await page.goto('https://index-2d7a4.firebaseapp.com', {waitUntil: 'networkidle0'} );
await page.content();
console.log('
~~3~~')
let status = await page.evaluate( (body) => {
document.querySelector('varan-input').innerText = body
return true
},body)
console.log('~~4~~~~', status)
await browser.close();
res.end(body)
})
};

And it's not work ((

Log

2019-05-11T20:31:45.506Z success Saved lockfile.
2019-05-11T20:31:45.507Z warning No license field
2019-05-11T20:31:45.510Z success Saved 7 new dependencies.
2019-05-11T20:31:45.510Z info Direct dependencies
2019-05-11T20:31:45.511Z 鈹斺攢
@now
/[email protected]
2019-05-11T20:31:45.511Z info All dependencies
2019-05-11T20:31:45.511Z 鈹溾攢
@now
/[email protected]
鈹溾攢
@now
/[email protected]
鈹溾攢
@zeit
/[email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹溾攢 [email protected]
鈹斺攢 [email protected]
2019-05-11T20:31:45.512Z Done in 2.20s.
2019-05-11T20:31:48.835Z running builder.exports.build...
2019-05-11T20:31:48.835Z downloading user files...
2019-05-11T20:31:49.223Z installing dependencies for user's code...
2019-05-11T20:31:49.224Z installing to /tmp/5545ccb9
2019-05-11T20:31:49.454Z running user script...
2019-05-11T20:31:49.454Z compiling entrypoint with ncc...
2019-05-11T20:31:49.985Z ncc: Version 0.18.5
ncc: Compiling file index.js
2019-05-11T20:31:50.356Z ncc: Module directory "/tmp/5545ccb9/node_modules/chrome-aws-lambda/source" attempted to require "puppeteer" but could not be resolved, assuming external.
2019-05-11T20:31:50.789Z ncc: Module directory "/tmp/5545ccb9/node_modules/chrome-aws-lambda/source/puppeteer/lib" attempted to require "puppeteer" but could not be resolved, assuming external.
2019-05-11T20:31:50.789Z ncc: Module directory "/tmp/5545ccb9/node_modules/chrome-aws-lambda/source/puppeteer/lib" attempted to require "puppeteer" but could not be resolved, assuming external.
2019-05-11T20:31:51.004Z ncc: Module directory "/tmp/5545ccb9/node_modules/debug/src" attempted to require "supports-color" but could not be resolved, assuming external.
2019-05-11T20:31:51.343Z ncc: Module directory "/tmp/5545ccb9/node_modules/ws/lib" attempted to require "bufferutil" but could not be resolved, assuming external.
2019-05-11T20:31:51.344Z ncc: Module directory "/tmp/5545ccb9/node_modules/ws/lib" attempted to require "utf-8-validate" but could not be resolved, assuming external.
2019-05-11T20:31:51.376Z ncc: Module directory "/tmp/5545ccb9/node_modules/https-proxy-agent/node_modules/debug/src" attempted to require "supports-color" but could not be resolved, assuming external.
2019-05-11T20:32:02.613Z running builder.exports.prepareCache...
2019-05-11T20:37:28.504Z 1
2019-05-11T20:37:29.641Z ~2~
2019-05-11T20:37:35.498Z 3
2019-05-11T20:37:35.501Z 4~~ true

You could pass in -e packageName for every database package you'r not using.

@dirkdev98 what do you mean by this? Where do you put -e?

Has anybody managed to get Typeorm to work in a Now v2?
Once I add it to my Express app, I see Cannot GET in browser and there is nothing in logs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

omar2205 picture omar2205  路  5Comments

j picture j  路  3Comments

paulogdm picture paulogdm  路  5Comments

rauchg picture rauchg  路  3Comments

coetry picture coetry  路  5Comments