SIP.js icon indicating copy to clipboard operation
SIP.js copied to clipboard

PegJS issues when running SIP.js on Node

Open tsuriga opened this issue 9 years ago • 2 comments

Is the npm package supposed to work out of the box on Node? I get errors when doing the following:

mkdir sipjstest
cd sipjstest
npm init
npm i sip.js --save
echo "const SIP = require('sip.js');" > index.js

node index.js
~/code/sipjstest/node_modules/sip.js/src/Grammar/src/Grammar.pegjs:14
HEXDIG  = [0-9a-fA-F]
             ^

SyntaxError: Invalid or unexpected token
    at createScript (vm.js:80:10)
    ....
    at Object.<anonymous> (~/code/sipjstest/node_modules/sip.js/src/Grammar.js:2:15)

If I do things suggested in node_modules/sip.js/src/Grammar/README.md:

Notes:

  • npm install is missing from the instructions, otherwise it'll just say "sh: webpack: command not found"
  • need to add --display-reasons --display-module for webpack to the build script in package.json to get the full output that I refer to later
npm install
npm install -g pegjs
npm run build

Grammar is referenced on two lines:

  [30] ./src/Grammar.js 348 bytes {0} {1} [built]
       cjs require ./Grammar [2] ./src/SIP.js 45:14-34
  [31] ./src/Grammar/src/Grammar.pegjs 65.9 kB {0} {1} [built]
       cjs require ./Grammar/src/Grammar.pegjs [30] ./src/Grammar.js 2:14-52

but that just builds it into node_modules/sip.js/dist/sip.js and doesn't affect node index.js run referenced above.

What I ended up doing just to get rid of errors is I ran $ cd node_modules/sip.js && pegjs dist/Grammar.js src/Grammar/src/Grammar.pegjs and then copied the contents of node_modules/sip.js/dist/Grammar.js manually into node_modules/sip.js/Grammar.js.

JsSIP seems to have the Grammar.js working out of the box just fine. There could be some instructions for Node.js setups in the README if one's supposed to do something differently.

tsuriga avatar Nov 02 '17 12:11 tsuriga

The latest version, which came out yesterday, solves this. It was not published to NPM, but will be shortly.

Sorry for the inconvenience, James

james-criscuolo avatar Nov 02 '17 13:11 james-criscuolo

Duplicate of #453. Just published 0.8.3 to npm which fixes this. Sorry for the confusion.

egreenmachine avatar Nov 02 '17 13:11 egreenmachine