KEMBAR78
npm creates incorrect cmd shim for jezebel package on windows · Issue #3380 · npm/npm · GitHub
Skip to content
This repository was archived by the owner on Aug 11, 2022. It is now read-only.
This repository was archived by the owner on Aug 11, 2022. It is now read-only.

npm creates incorrect cmd shim for jezebel package on windows #3380

@basbossink

Description

@basbossink

When trying to run jezebel on windows after installing it with npm, it fails. C:\Users\AppData\Roaming\npm\jezebel.cmd looks like this:

:: Created by npm, please don't edit manually.
@IF EXIST "%~dp0\NODE_PATH=./lib:$NODE_PATH.exe" (
  "%~dp0\NODE_PATH=./lib:$NODE_PATH.exe"  node %~dp0\node_modules\jezebel\bin\jezebel" %*
) ELSE (
     NODE_PATH=./lib:$NODE_PATH  node "%~dp0\node_modules\jezebel\bin\jezebel"   %*
)

Which is syntactically incorrect.
Looking at the jezebel repository the bin\jezebel file has the following first line:

#!/usr/bin/env NODE_PATH=./lib:$NODE_PATH node     

Looking at the npm source code, specifically node_modules\cmd-shim:22 shows:

    , shebangExpr = /^#\!\s*(?:\/usr\/bin\/env)?\s*([^ \t]+)(.*)$/

This regular expression was not built with the possibillity of variable declarations in mind.

It should be adapted to extract the variable declarations and translate them to the proper cmd syntax:

set NODE_PATH=.lib:%NODE_PATH%

in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions