Ncc: Package issue `@google-cloud/vision`

Created on 21 May 2019  路  20Comments  路  Source: vercel/ncc

Steps to reproduce

yarn init -y
yarn add @google-cloud/vision
echo "let foo = require('@google-cloud/vision')" > index.js
ncc build index.js

Error Message (0.19.0-beta.1)

Unhandled reject during build time using the master branch.

ncc: Version 0.19.0-beta.1
ncc: Compiling file index.js
(node:14428) UnhandledPromiseRejectionWarning: TypeError: replacement content must be a string
    at MagicString.overwrite (evalmachine.<anonymous>:1:531199)
    at e.exports (evalmachine.<anonymous>:1:177864)
    at Object.e.exports (evalmachine.<anonymous>:1:166144)
    at LOADER_EXECUTION (evalmachine.<anonymous>:1:15237)
    at runSyncOrAsync (evalmachine.<anonymous>:1:15248)
    at iterateNormalLoaders (evalmachine.<anonymous>:1:16844)
    at iterateNormalLoaders (evalmachine.<anonymous>:1:16712)
    at evalmachine.<anonymous>:1:16940
    at runSyncOrAsync (evalmachine.<anonymous>:1:15394)
    at iterateNormalLoaders (evalmachine.<anonymous>:1:16844)
(node:14428) 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:14428) [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.

Error Message (0.18.5)

With ncc 0.18.5 the code builds but fails during run time with node dist.

internal/validators.js:125
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type number
    at validateString (internal/validators.js:125:11)
    at Object.dirname (path.js:1260:5)
    at Object.module.exports.module.exports.application/andrew-inset (/Users/styfle/Code/foo/google-vis/dist/index.js:17004:36)
    at __webpack_require__ (/Users/styfle/Code/foo/google-vis/dist/index.js:22:30)
    at Object.module.exports.module.exports.name (/Users/styfle/Code/foo/google-vis/dist/index.js:40480:25)
    at __webpack_require__ (/Users/styfle/Code/foo/google-vis/dist/index.js:22:30)
    at Object.module.exports.Object.defineProperty.value (/Users/styfle/Code/foo/google-vis/dist/index.js:65801:16)
    at __webpack_require__ (/Users/styfle/Code/foo/google-vis/dist/index.js:22:30)
    at Object.<anonymous> (/Users/styfle/Code/foo/google-vis/dist/index.js:20434:13)
    at __webpack_require__ (/Users/styfle/Code/foo/google-vis/dist/index.js:22:30)
package issue priority

Most helpful comment

Any update or workaround for this issue? It's totally preventing me to migrate my project from v1 to v2 :(

All 20 comments

Having similar issues with @google-cloud/datastore

The main feature necessary for getting this to work is https://github.com/zeit/webpack-asset-relocator-loader/issues/37.

Having similar issues with @google-cloud/speech

Having similar issues with googleapis.

The main feature necessary for getting this to work is zeit/webpack-asset-relocator-loader#37.

@guybedford We would have to install this package so that we can run the google SDKs in the meantime?
Do you have an example?

Same issue with @google-cloud/tasks.

Any update or workaround for this issue? It's totally preventing me to migrate my project from v1 to v2 :(

I confirm, it's rather critical.... We are forced to maintain projects in v1 (and pay accordingly)

The fix for this turned out to be simply installing the latest npm install google-proto-files@1 version, which is then resolved by the vision library and emitted properly in the asset emission process.

(and running ncc cache clean after doing that)

Unfortunately that did not solve the problem for me.

Getting this error now: TypeError: Path must be a string. Received 5583

Also not sure where to run the ncc command, if locally or as a pre-install script

I can confirm that I am still receiving an error after the suggested fix @guybedford, but only when running now dev. It compiles, and runs fine when deployed with now, or when just manually compiling the file using ncc build command. Here is the error I am getting locally when running now dev:

TypeError: Path must be a string. Received 290
    at assertPath (path.js:28:11)
    at Object.dirname (path.js:1349:5)
    at Object.module.exports.module.exports (/private/var/folders/mx/5d839r0x38jbrxgqk0lj3nk40000gn/T/zeit-fun-973c70fd7ffa3/index.js:44625:36)
    at __webpack_require__ (/webpack/bootstrap:19:1)
    at Object.module.exports.PARAM_REGEXP (/private/var/folders/mx/5d839r0x38jbrxgqk0lj3nk40000gn/T/zeit-fun-973c70fd7ffa3/index.js:81755:25)
    at __webpack_require__ (/webpack/bootstrap:19:1)
    at Object.module.exports.Object.defineProperty.value (/private/var/folders/mx/5d839r0x38jbrxgqk0lj3nk40000gn/T/zeit-fun-973c70fd7ffa3/index.js:7791:16)
    at __webpack_require__ (/webpack/bootstrap:19:1)
    at Object.module.exports.Object.defineProperty.value (/private/var/folders/mx/5d839r0x38jbrxgqk0lj3nk40000gn/T/zeit-fun-973c70fd7ffa3/index.js:6985:22)
    at __webpack_require__ (/webpack/bootstrap:19:1)

@ecjs thanks for the update here - the fix referred to above is with the ncc 0.19.0-beta which is not currently in use in now. We're hoping to push that soon, which with some luck should fix this for you.

Awesome! Thanks for the help on this!

ncc @0.19 has been released, and the final fix is in fact simply the workaround described in https://github.com/zeit/ncc/pull/420#issuecomment-501226766.

And see the package-support.md docs

Any luck we can get the @now/node-server to use [email protected]? Or is there a workaround I can use to deploy before it's updated in @now/node-server?

Having the same issue with @google-cloud/pubsub.

Any luck we can get the @now/node-server to use [email protected]? Or is there a workaround I can use to deploy before it's updated in @now/node-server?

Having the same issue with @google-cloud/pubsub.

Also getting an issue with @google-cloud/pubsub, @sam-rad did you manage to resolve ?

@Jimtattersall It should be fixed by now, no? See https://github.com/zeit/now/blob/canary/packages/now-node/package.json#L31

I didn't try this though.

On my side the problem still doesn't seem to be solved, especially with the google vision library :

Error: The include `/private/var/folders/ft/nn73dfqn7glc_sw29n9c59pr0000gn/T/zeit-fun-902f177d1816e/v1/images/protos/google/cloud/vision/v1/image_annotator.proto` was not found.
Was this page helpful?
0 / 5 - 0 ratings