vercel / pkg

Package your Node.js project into an executable
https://npmjs.com/pkg
MIT License
24.33k stars 1.02k forks source link

Package Node-Red project #407

Closed tkrzyford closed 6 years ago

tkrzyford commented 6 years ago

I'm attempting to run pkg on an express project that contains Node-Red, but when I attempt to run the exe it throws the error "Node-RED not built". Everything runs fine when done locally.

iba-jsykes commented 6 years ago

To anyone else looking at using this for node-red, you'll have to do as the readme says and change some require paths to get it to work properly, the error above is more than likely caused by the checkBuild method which cant find red.min.js .

aurelhann commented 6 years ago

You need to build and set correctly the assets of pkg...

spatel626 commented 6 years ago

Does anyone have a working package.json file with the correct assets and scripts of pkg for node-red?

I am getting the same "Node-RED not built" error when running the exe

tkrzyford commented 6 years ago

I ended up including the entire node-red* directories and that solved the issue. Not the most efficient practice, but it worked.

spatel626 commented 6 years ago

oh I see. I tried that too but it wouldn't work for me.

Did you clone the repo from Github or did you install via npm install node-red?

I cloned my project to C:\xampp\htdocs\node-red and I am trying to run pkg from there. I also installed node-red via npm as well but that created a different folder structure without red.js inside C:\Users\USER\.node-red

I noticed that grunt build is used in the package.json when cloning from Git but installing via npm doesn't have any build option included in there.

Would you mind sharing your package.json so I can see how you got it working?

Here is what my package.json currently looks like:

{
  "name": "node-red",
  "version": "0.19.1",
  "description": "A visual tool for wiring the Internet of Things",
  "homepage": "http://nodered.org",
  "license": "Apache-2.0",
  "repository": {
    "type": "git",
    "url": "https://github.com/node-red/node-red.git"
  },
  "main": "red/red.js",
  "scripts": {
    "start": "node red.js",
    "test": "grunt",
    "build": "grunt build"
  },
  "pkg": {
    "scripts": [
      "/red/**/*.js"
    ],
    "targets": [
      "node8"
    ]
  },
  "bin": {
    "node-red": "./red.js",
    "node-red-pi": "bin/node-red-pi"
  },
  "contributors": [
    {
      "name": "Nick O'Leary"
    },
    {
      "name": "Dave Conway-Jones"
    }
  ],
  "keywords": [
    "editor",
    "messaging",
    "iot",
    "flow"
  ],
  "dependencies": {
    "ajv": "6.5.2",
    "basic-auth": "2.0.0",
    "bcryptjs": "2.4.3",
    "body-parser": "1.18.3",
    "cheerio": "0.22.0",
    "clone": "2.1.2",
    "cookie": "0.3.1",
    "cookie-parser": "1.4.3",
    "cors": "2.8.4",
    "cron": "1.3.0",
    "denque": "1.3.0",
    "express": "4.16.3",
    "express-session": "1.15.6",
    "fs-extra": "5.0.0",
    "fs.notify": "0.0.4",
    "hash-sum": "1.0.2",
    "i18next": "11.6.0",
    "is-utf8": "0.2.1",
    "js-yaml": "3.12.0",
    "json-stringify-safe": "5.0.1",
    "jsonata": "1.5.4",
    "media-typer": "0.3.0",
    "memorystore": "1.6.0",
    "mqtt": "2.18.3",
    "multer": "1.3.1",
    "mustache": "2.3.1",
    "node-red-node-email": "0.1.*",
    "node-red-node-feedparser": "^0.1.12",
    "node-red-node-rbe": "0.2.*",
    "node-red-node-twitter": "^1.1.0",
    "nopt": "4.0.1",
    "oauth2orize": "1.11.0",
    "on-headers": "1.0.1",
    "passport": "0.4.0",
    "passport-http-bearer": "1.0.1",
    "passport-oauth2-client-password": "0.1.2",
    "raw-body": "2.3.3",
    "request": "2.88.0",
    "semver": "5.5.0",
    "sentiment": "2.1.0",
    "uglify-js": "3.4.7",
    "when": "3.7.8",
    "ws": "1.1.5",
    "xml2js": "0.4.19"
  },
  "optionalDependencies": {
    "bcrypt": "~2.0.0"
  },
  "devDependencies": {
    "chromedriver": "^2.41.0",
    "grunt": "~1.0.3",
    "grunt-chmod": "~1.1.1",
    "grunt-cli": "~1.2.0",
    "grunt-concurrent": "~2.3.1",
    "grunt-contrib-clean": "~1.1.0",
    "grunt-contrib-compress": "~1.4.0",
    "grunt-contrib-concat": "~1.0.1",
    "grunt-contrib-copy": "~1.0.0",
    "grunt-contrib-jshint": "~1.1.0",
    "grunt-contrib-uglify": "~3.4.0",
    "grunt-contrib-watch": "~1.1.0",
    "grunt-jsonlint": "~1.1.0",
    "grunt-mocha-istanbul": "5.0.2",
    "grunt-nodemon": "~0.4.2",
    "grunt-sass": "~2.0.0",
    "grunt-simple-mocha": "~0.4.1",
    "grunt-webdriver": "^2.0.3",
    "http-proxy": "^1.16.2",
    "istanbul": "0.4.5",
    "mocha": "^5.2.0",
    "should": "^8.4.0",
    "sinon": "1.17.7",
    "stoppable": "^1.0.6",
    "supertest": "3.1.0",
    "wdio-chromedriver-service": "^0.1.3",
    "wdio-mocha-framework": "^0.6.2",
    "wdio-spec-reporter": "^0.1.5",
    "webdriverio": "^4.13.1",
    "node-red-node-test-helper": "^0.1.7"
  },
  "engines": {
    "node": ">=4"
  }
}
dheerajaggarwal commented 4 years ago

I have faced the same issue when using the js-yaml dependency in my project. More specifically js-yaml uses the esprima dependency that was causing the issue.

I am not using the Node-Red project. But I found the same dependency js-yaml over here as well so I thought to share this information.