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

Can't npm install a module packed with ncc on Windows #1026

Open
pmhpereira opened this issue Jan 12, 2023 · 1 comment
Open

Can't npm install a module packed with ncc on Windows #1026

pmhpereira opened this issue Jan 12, 2023 · 1 comment

Comments

@pmhpereira
Copy link

pmhpereira commented Jan 12, 2023

Hello all,

Using vercel/ncc 0.36.0, I'm running into an odd issue that happens on Windows.

Running ncc build src/index.ts -o dist generates a dist/index.js file that starts with:

#!/usr/bin/env node
/******/ (() => { // webpackBootstrap
/******/ 	var __webpack_modules__ = ({

/***/ 83633:
/***/ ((module, __unused_webpack_exports, __nccwpck_require__) => {

...
rest of the file

If I try to npm i -g this module and then run it directly from console, it fails with some syntax errors.
Opening the generated scripts from the npm i -g command, shows that it contains the string /******/ (() => { // webpackBootstrap that shouldn't be there:

#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node
/******/" ]; then
  exec "$basedir/node
/******/" (() => { // webpackBootstrap "$basedir/node_modules/@my-lib/cli/dist/index.js" "$@"
else 
  exec node
/******/ (() => { // webpackBootstrap "$basedir/node_modules/@my-lib/cli/dist/index.js" "$@"
fi

If you notice, it is the same string as the 2nd line of dist/index.js.

Any guidance on how to solve this is appreciated.

Thanks!

@pmhpereira pmhpereira changed the title Can't npm install a module packed with ncc Can't npm install a module packed with ncc on Windows Jan 12, 2023
@bobvandevijver
Copy link

This is the same issue as #845. You can solve it manually by adding a blank line between the #!/usr/bin/env node and the rest of the generated code.

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

2 participants