Skip to content

NPM Run Configuration: cannot execute some scripts from package.json #1899

Open

Description

@nimo23

I have a NPM run configuration pointing to an existing package.json (which is not in the root-directory of the project but within a subfolder):

Image

However, executing the run configuration does not work:

npm error code ENOENT
npm error syscall open
npm error path /Users/ev/ide/app/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/Users/ev/ide/app/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /Users/ev/.npm/_logs/2025-08-03T00_54_31_316Z-debug-0.log

The log says that package.json cannot be found in /Users/ev/ide/app/package.json, although it should look in /Users/ev/ide/app/src/main/webui/package.json as specified in the launch configuration. I also tried with absolute path (= /Users/ev/ide/app/src/main/webui/package.json) in the launch configuration - it shows the same error.

  • On Mac OS
  • Eclipse Version: 2025-03 (4.35.0)
  • Wild Web Developer: 1.3.10.202502071606

Activity

  1. mickaelistria commented on Aug 3, 2025

    @mickaelistria
    Contributor

    I'm having trouble to reproduce with a simple project.
    I tried

    • project (imported as project in the IDE, root element in the Project Navigator)
      • sub/
        • package.json (with content
    {
      "scripts": {
         "test": "echo lol"
      }
    }

    I think try Run As > NPM... on context-menu of the package.json file)
    And I get a console showing the exepcted

    > test
    > echo lol
    
    lol
    

    Can you please try finding such a minimal project that allows you to reproduce the issue and shared more detailed steps to reproduce from scratch?

  2. nimo23 commented on Aug 3, 2025

    @nimo23
    Author

    Ok, adding a run config with test or install works for me, too. And there is no subpath-issue but with executing scripts such as dev, build, lint or preview:

      "scripts": {
        "test": "echo lol",
        "dev": "vite",
        "build": "tsc -b && vite build",
        "lint": "eslint .",
        "preview": "vite preview"
      },
    

    For example, adding run config build:

    Image

    and executing, leads to:

    Unknown command: "build"
    
    Did you mean this?
      npm run build # run the "build" package script
    To see a list of supported npm commands, run:
      npm help
    

    How to solve this?

    Reproducer:

    webui.zip

  3. changed the title [-]NPM Run Configuration: does not work if `package.json` is within subpath[/-] [+]NPM Run Configuration: cannot execute some scripts from `package.json`[/+] on Aug 3, 2025
  4. mickaelistria commented on Aug 3, 2025

    @mickaelistria
    Contributor

    I still cannot reproduce the issue. From the given reproducer project, can you please share details to reproduce from a clean workspace (including how the project is imported, what UI entry-points do you use to run npm..._ ?

  5. nimo23 commented on Aug 3, 2025

    @nimo23
    Author

    including how the project is imported

    1. I created the project from within the Eclipse workspace directory by

    npm create vite@latest webui -- --template react-ts

    1. Then I created a new Eclipse static web project called "webui" and the content of the created webui becomes visible.

    2. Then I executed npm install

    3. Then I created the launch configuration for dev (see picture above)

    4. Then I wanted to execute the Npm command dev. Executing npm run dev from the terminal works without issues, but executing it from the Launch configuration (see picture above), does not work - it shows in the terminal:

    Unknown command: "build"
    
    Did you mean this?
      npm run build # run the "build" package script
    To see a list of supported npm commands, run:
      npm help
    

    what UI entry-points do you use to run npm

    cd webui
    npm install 
    npm run dev //works from the terminal but not from the Launch configuration (see above)
    

    I also tried using run build instead of build:

    Image

    But it doesn't work either - the terminal output:

    > webui@0.0.0 build
    > tsc -b && vite build
    
    env: node: No such file or directory
    
  6. mickaelistria commented on Aug 3, 2025

    @mickaelistria
    Contributor

    It looks like node is not well detected on your machine; and npm may be misconfigured. It could again be different on your machine because it's a mac, and as you probably notice, mac tends to be undertested/undersupported by the community by lack of maintainers using it.

    In Help > About Eclipse IDE > Installation Details > Plugins tab; please search for "node.js" and report what you see there.

  7. nimo23 commented on Aug 3, 2025

    @nimo23
    Author

    In Help > About Eclipse IDE > Installation Details > Plugins tab; please search for "node.js" and report what you see there.

    Image

    It looks like node is not well detected on your machine; and npm may be misconfigured.

    node/npm are globally available from the terminal:

    which node
    /opt/homebrew/bin/node
    
    which npm
    /opt/homebrew/bin/npm
    

    Running node/npm from the Eclipse terminal also works, BUT ONLY if I set Arguments: --login (btw: on a new Eclipse installation, it does not set Arguments: --login , so perhaps it would be useful to set this by default):

    Image

    I assume that Eclipse WWD or Eclipse NPM Launch Configuration wants to execute its command without terminal argument --login. Because without --login, node/npm is indeed not found by eclipse terminal and launch configuration:

    // Executed from within the Eclipse Terminal without --login argument
    
    which node
    node not found
    
    which npm
    npm not found
    

    To sum up:

    Eclipse WWD or Eclipse NPM Launch Configuration should always run their tasks with the terminal argument --login. Unfortunately, the Eclipse terminal settings are delegated to Eclipse NPM Launch Configuration. Therefore, it would be good if Eclipse NPM Launch Configuration could use the custom Eclipse terminal settings or always run its tasks with --login. Alternatively, an input field could be added where the user can enter terminal arguments when running a task:

    Image
  8. trolst commented on Dec 17, 2025

    @trolst

    I am experiencing the issue with a NPM run configuration where the package.json is not in the root-directory which was first mentioned by @nimo23.

    Intention:
    I want to create a run configuration with relative paths/variables to put into my code repository. So every developer working with this repository may run these configurations in there own environment.
    Image

    Problem:
    After setting up my project structure and adding NPM run configurations, I got errors when running these configurations.
    Image

    Investigation:
    Because I used 'Save as' -> 'Shared file' when creating the run configuration, I had a look at the run configuration file:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <launchConfiguration type="org.eclipse.wildwebdeveloper.launchConfiguration.NPMLaunch">
        <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
        <stringAttribute key="org.eclipse.debug.core.ATTR_WORKING_DIRECTORY" value=""/>
        <stringAttribute key="program" value="${workspace_loc:/npm-launch-test/.build/package.json}"/>
        <stringAttribute key="runtimeArgs" value="run test"/>
    </launchConfiguration>
    

    The configuration shows a empty string value for org.eclipse.debug.core.ATTR_WORKING_DIRECTORY. So I tried to set this value to the package.json location:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <launchConfiguration type="org.eclipse.wildwebdeveloper.launchConfiguration.NPMLaunch">
        <booleanAttribute key="org.eclipse.debug.core.ATTR_FORCE_SYSTEM_CONSOLE_ENCODING" value="false"/>
        <stringAttribute key="org.eclipse.debug.core.ATTR_WORKING_DIRECTORY" value="${workspace_loc:/npm-launch-test/.build}"/>
        <stringAttribute key="program" value="${workspace_loc:/npm-launch-test/.build/package.json}"/>
        <stringAttribute key="runtimeArgs" value="run test"/>
    </launchConfiguration>
    

    Now the run configuration seem to work and can be executed from the run configurations menu or context menu:
    Image
    Image

    But as soon as I try to edit the run configuration, the org.eclipse.debug.core.ATTR_WORKING_DIRECTORY value gets reset, and it does not work anymore. Sometimes it is empty, sometimes it points to the location of the shared run configuration file which both makes the run configuration stop working.

    I set up a simple eclipse project to reproduce the behaviour:
    npm-launch-test.zip

    The project and its run configurations are properly set and ready to launch from context menu:
    Image

    Once you open the run configuration wizard and press 'Run', it should be broken:
    Image


    While investigation the issue, I noticed another issue with the run configuration. It is not possible to execute scripts with whitespace in its name. It seams the quotation of the command parameters is broken. Please find the run configuration in my npm-launch-test project:

    // package.json
    {
      "name": "npm-launch-test",
      "version": "1.0.0",
      "description": "Eclipse npm launch configuration test.",
      "keywords": [
        "test",
        "eclipse",
        "launch"
      ],
      "license": "ISC",
      "author": "",
      "type": "commonjs",
      "main": "index.js",
      "scripts": {
        "test": "test success",
        "test with space": "test with space success"
      }
    }
    
    Image

    Result:

    npm error Missing script: ""test"
    npm error
    npm error Did you mean this?
    npm error   npm test # Test a package
    

    Executing npm run "test with space" from terminal works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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