Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SyntaxError: Unexpected token #168

Closed
teto opened this issue Apr 2, 2020 · 6 comments
Closed

SyntaxError: Unexpected token #168

teto opened this issue Apr 2, 2020 · 6 comments

Comments

@teto
Copy link

teto commented Apr 2, 2020

Hi,

I am trying to package this plugin for nixos. I don't know much about node and I believe it's not that well supported on nixos so don't hesitate to be verbose in your explanation.
:MarkdownPreview fails with

|| pkg/prelude/bootstrap.js:130
|| {"mode":33188,"size":3132,"isFileValue":true,"isDirectoryValue":false}["supports-colors.js"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["trap.js","zalgo.js"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["america.js","zebra.js","rainbow.js","random.js"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["package.json","index.js","HISTORY.md","LICENSE","README.md","db.json"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["charset.js","encoding.js","language.js","mediaType.js"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["isarray"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["package.json","index.js"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["isarray"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["supports-color","has-flag"]{"mode":16877,"size":0,"isFileValue":false,"isDirectoryValue":true}["streams"]{"mode":
|| SyntaxError: Unexpected token :
||     at new Script (vm.js:75:7)
||     at readPrelude (internal/bootstrap/node.js:175:17)
||     at internal/bootstrap/node.js:182:22
||     at internal/bootstrap/node.js:189:8
||     at startup (internal/bootstrap/node.js:190:6)
||     at bootstrapNodeJSCore (internal/bootstrap/node.js:608:3)

some checkhealth

health#mkdp#check
========================================================================
  - INFO: Platform: linux
  - INFO: Nvim Version: NVIM v0.5.0-dev
  - INFO: Pre build: /nix/store/l7izi3v63vp0vr16aq5s8msbqyhxdgb6-vimplugin-markdown-preview-nvim-2020-03-26/share/vim-plugins/markdown-preview-nvim/app/bin/markdown-preview-linux
  - INFO: Pre build version: pkg/prelude/bootstrap.js:130
  - OK: Using pre build

## Node.js provider (optional)
  - INFO: Node.js: v10.19.0
  - INFO: Nvim node.js host: /nix/store/h6dn0a2ap5k0nlfjwfkakhiagxrzjbai-node_neovim-4.8.0/bin/neovim-node-host
  - OK: Latest "neovim" npm/yarn package is installed: 4.8.0

Might be related #118

@iamcco
Copy link
Owner

iamcco commented Apr 4, 2020

Seems the pre build bundle by PKG is not support with your system. Use nodejs and source code instead.

@teto
Copy link
Author

teto commented Apr 5, 2020

I see, i will look for another strqtegy, I thought it could be a node version/pkg mismatch

@teto teto closed this as completed Apr 5, 2020
@epeery
Copy link

epeery commented Apr 9, 2020

@teto Did you ever manage to get the derivation working?

@teto
Copy link
Author

teto commented Apr 9, 2020

nope, I've been using NixOS/nixpkgs#84213 instead.

My WIP derivation was

  markdown-preview-nvim = let
    version = "0.0.9";
    index_js = fetchzip {
        # TODO fix linux/macos
        url = "https://github.com/iamcco/markdown-preview.nvim/releases/download/v${version}/markdown-preview-linux.tar.gz";
        sha256 = "0lxk8h4q64g21ywgnfq2hl431ap14kq4hxlacfyhz860jll3qf0j";
      };
    nodePackages = import ./nodepkgs.nix {
      inherit (prev) pkgs;
    #   inherit (prev.stdenv.hostPlatform) system;
    };
      # node2nix ./package.json
  in prev.markdown-preview-nvim.overrideAttrs(old: {
    # you still need to enable the node js provider in your nvim config
    # TODO fix folder
    buildInputs = (old.buildInputs or []) ++ [ autoPatchelfHook glibc pkgs.gcc-unwrapped.lib ] ++ (with nodePackages; [

    ]);

    # first it checks if file is
    # TODO use install -D
      # mkdir -p $out/share/vim-plugins/coc-nvim/app
      # ${glibc.out}/lib/ld-linux-x86-64.so.2
      # --set-interpreter $NIX_CC/nix-support/dynamic-linker
    #       patchelf  $out/share/vim-plugins/markdown-preview-nvim/app/bin/markdown-preview-linux
    postInstall = ''
      set -x

      mkdir -p $out/share/vim-plugins/markdown-preview-nvim/app/bin
      cp ${index_js}/markdown-preview-linux $out/share/vim-plugins/markdown-preview-nvim/app/bin

    '';

  });

@epeery
Copy link

epeery commented Apr 9, 2020

I attempted to compile the binary on my end with yarn run build but it seems like PKG doesn't play well with NixOS

> [email protected]
> Fetching base Node.js binaries to PKG_CACHE_PATH
  fetched-v10.17.0-linux-x64   [====================] 100%
  fetched-v10.17.0-macos-x64   [====================] 100%
  fetched-v10.17.0-win-x64     [====================] 100%
> Warning Failed to make bytecode node10-x64 for file /snapshot/markdown-preview.nvim/app/index.js error (write EPIPE)

I also found this issue in the PKG repo that seems similar to ours.

vercel/pkg#321

@iclanzan
Copy link

I took a stab at packaging this for NixOS:
NixOS/nixpkgs#97781

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants