Pkg: PKG Dependency has an issue

Created on 30 Mar 2020  路  10Comments  路  Source: vercel/pkg

Hi! There is an issue with fs-extra. Even when you try to get a version, you will get this:

pkg -v

/usr/lib/node_modules/pkg/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object. (/usr/lib/node_modules/pkg/node_modules/fs-extra/lib/mkdirs/index.js:3:44)

This happens on all versions after 4.4.0

Most helpful comment

I am on node v14.7.0 and I am still seeing the issue.

All 10 comments

I got the same issue

Happens to me as well. I'm trying to run it in Google Cloud Build, using the gcr.io/cloud-builders/npm builder image. I've tried the latest 4.4.5, and then downgraded to 4.4.4. It has been running well for years, and now suddenly it broke. Here's the log:

npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
/usr/local/bin/pkg -> /usr/local/lib/node_modules/pkg/lib-es5/bin.js
+ [email protected]
added 126 packages from 152 contributors in 5.497s
/usr/local/lib/node_modules/pkg/node_modules/pkg-fetch/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
      } catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/pkg/node_modules/pkg-fetch/node_modules/fs-extra/lib/mkdirs/index.js:3:44)

This happened to me as well. I do not know how to solve this. Why it is happening even in older tags if they did not change?

  • pkg -t node8.16.0-linux-armv7 --output result package.json
    /node/node-v8.9.4/lib/node_modules/pkg/node_modules/pkg-fetch/node_modules/fs-ex tra/lib/mkdirs/make-dir.js:86
    } catch {
    ^

SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object. (/node/node-v8.9.4/lib/node_modules/pkg/node_modules/p kg-fetch/node_modules/fs-extra/lib/mkdirs/index.js:3:44)

I have encountered this issue as well with the same error. My workaround is to enforce an older version, [email protected] and [email protected] which uses [email protected] instead. This is done by:

  1. installing [email protected] with "npm install -g [email protected]"
  2. modifying "/usr/local/lib/node_modules/pkg/package.json", setting pkg-fetch to "2.6.4" instead of "^2.6.4"
  3. removing "/usr/local/lib/node_modules/pkg/node_modules"
  4. calling npm update in "/usr/local/lib/node_modules/pkg"

Ditto

Happens to me as well. I'm trying to run it in Google Cloud Build, using the gcr.io/cloud-builders/npm builder image. I've tried the latest 4.4.5, and then downgraded to 4.4.4. It has been running well for years, and now suddenly it broke. Here's the log:

npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
/usr/local/bin/pkg -> /usr/local/lib/node_modules/pkg/lib-es5/bin.js
+ [email protected]
added 126 packages from 152 contributors in 5.497s
/usr/local/lib/node_modules/pkg/node_modules/pkg-fetch/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
      } catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/pkg/node_modules/pkg-fetch/node_modules/fs-extra/lib/mkdirs/index.js:3:44)

I had the same issue using node 8.10.0
After upgrading my node version to 10.13.0 the error was gone

I am on node v14.7.0 and I am still seeing the issue.

Same on v12.16.1

Happens to me with node 12.18.3...

After Updating Node version Rebuild node packages

cd /to/root/of/your/project
npm rebuild
npm i -g pm2 && pm2 update

    =here 0 and dist/main.js change for your project
pm2 delete 0 && pm2 start dist/main.js

Link to the Answer of stackoverflow

This worked for me easily

Was this page helpful?
0 / 5 - 0 ratings