Skip to content

Use $npm_package variables #115

@g-div

Description

@g-div

nar is a really great project and I would like to use it to deploy my apps, but I'm experiencing a problem with my package.json.

I use to write my package.json like this:

{
  "name": "testpackage",
  "version": "0.0.1",
  "description": "A test package",
  "main": "index.js",
  "archive": {
    "dependencies": true,
    "devDependencies": false,
    "globalDependencies": [
      "npm"
    ]
  },
  "scripts": {
    "start": "node $npm_package_main",
    "build": "nar create --executable"
  },
  "devDependencies": {
    "nar": "^0.3.20"
  }
}

npm start works, but if I create an executable with nar create --executable and run it, I will get the following error:

Extracting files...
Extract [global-dependency] npm
Extract [package] testpackage
Running testpackage-0.0.1.nar
Run [start]: /usr/bin/env bash ~/testpackage/.nar/nar/scripts/node.sh $npm_package_main
Running application...
> module.js:338
>     throw err;
>     ^
> 
> Error: Cannot find module '/tmp/nar-testpackage-0.0.1-1446201800070/$npm_package_main'
>     at Function.Module._resolveFilename (module.js:336:15)
>     at Function.Module._load (module.js:286:25)
>     at Function.Module.runMain (module.js:475:10)
>     at startup (node.js:118:18)
>     at node.js:952:3
Error: Command failed with exit code: 1

The start script isn't able to recognize package.json variables.
Is there a way to achieve this ?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions