hi all, so i recently using signoz, and i have no...
# support
i
hi all, so i recently using signoz, and i have nodejs app, in this documentation, in section Set up OpenTelemetry and send data to SigNoz at number 5, it says, Run Application using node -r ./tracing.js index.js, but my developer running nodejs apps using npm run start is there any workaround to send data to signoz server ?
n
you can modify the start script in your package.json
i
Copy code
/app/src/App.js:1
import './App.css';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.0.1
v
Hey @Indra R I have modified the
package.json
of sample app to add support for
npm run start:noenv
It should work now, let me know if you face any issues.
i
hi vishal, thanks for reply, but i really didnt know what to do. what should i do ? what should i change ? any guidance really help me a lot. thanks
v
In your
package.json
update start script as below:
Copy code
"scripts": {
    "start": "node -r ./tracing.js index.js"
  },
i
ok, i will try to rebuild my image, because i already have this script in my package.json
hmm still failed, let met tried with your sample app
Copy code
npm ERR! Missing script: "start"
npm ERR! 
npm ERR! Did you mean one of these?
npm ERR!     npm star # Mark your favorite packages
npm ERR!     npm stars # View packages marked as favorites
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-11-28T12_44_36_062Z-debug-0.log
i tried build app using sample app above, and this error show up this is my dockerfile
Copy code
FROM node:19-alpine

WORKDIR /app

COPY package*.json ./

RUN npm install react-scripts --legacy-peer-deps
RUN npm install -g npm@9.1.2

COPY . .

EXPOSE 3000

CMD ["npm", "run", "start"]
anything i miss ?
v
For sample app you can use
npm run start:noenv
Replace
Copy code
CMD ["npm", "run", "start"]
With
Copy code
CMD ["npm", "run", "start:noenv"]
i
ahh yes, now its working, can you tell me what difference between them ? is using start:noenv is mandatory if using npm ?
will try with my nodejs app
v
@Indra R npm run is just a wrapper around nodejs So you can define any alias like
start
or
start:noenv
Like we did here: https://github.com/SigNoz/sample-nodejs-app/blob/592c7b35e38eb3607e97cc8708a40f81a5936066/package.json#L12
i
oke then, but i really need your help again if you can, so your sample is work, but mine is not, the error log is
Copy code
> app-core@0.1.0 start:noenv
> node -r ./tracing.js ./src/App.js

/app/src/App.js:1
import './App.css';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:360:18)
    at wrapSafe (node:internal/modules/cjs/loader:1088:15)
    at Module._compile (node:internal/modules/cjs/loader:1123:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at node:internal/main/run_main_module:23:47

Node.js v19.0.1
any suggestion for me ?
v
@Indra R It looks like an syntax issue related to importing of
./App.cs
which is unrelated to signoz.
i
oke then, thanks again