opcua icon indicating copy to clipboard operation
opcua copied to clipboard

NPM module cannot be imported

Open scranen opened this issue 5 years ago • 4 comments

Out of the box, loading the module does not seem to work for me.

Steps to reproduce

$ npm init -y && tsc --init
[...]
$ npm i opcua
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.

+ [email protected]
added 1 package from 1 contributor and audited 1 package in 0.987s
found 0 vulnerabilities
$ ts-node
> import Client from "opcua"

Expected result The import statement should succeed.

Actual result

$ ts-node
> import Client from "opcua"
[eval].ts:1:20 - error TS2306: File '(project-dir)/node_modules/opcua/index.d.ts' is not a module.

1 import Client from "opcua"
                     ~~~~~~~

Further information

$ npm --version
6.14.4
$ tsc --version
Version 3.8.3
$ npm ls opcua
[email protected] (project-dir)
└── [email protected] 

scranen avatar Apr 26 '20 08:04 scranen

Hey scranen,

thank you for this detailed issues description. I certainly need to work on the published version. I had to publish a version 1.0.0 quite early because I was given the name 'opcua' on npm. Someone else had the name but didn't use it and didn't have any code behind it. However after they've given me the name I had to release a new major version that includes at least some code from my repo. So that's about the history of this project on npm. The published version is certainly out of date. However I'm not yet ready to release a next version.

If you want to play with opcua it's probably the best to have a look the demo https://github.com/HBM/opcua/tree/master/demo. Clone the repo and then create your test project inside the demo folder. Some tsconfig.json and webpack.config.js are already there.

I'm curious, what are you using as the server?

Best regards, Mirco

zemirco avatar Apr 27 '20 09:04 zemirco

Thanks for the pointers, I'll have a look. The server I'm talking to is probably an old version of the one that's integrated in Codesys (didn't really look into it, I'm doing a quick and dirty PoC on a badly documented device), using my own solution to convert it to websocket.

scranen avatar Apr 29 '20 09:04 scranen

Hello, I'm looking to develop a mobile application via Ionic and Angular that implements your OPC-UA library. I have the same problem as @scranen : [ng] src/app/home/home/home.page.ts:10:20 - error TS2307: Cannot find module 'opcua'. [ng] 10 import Client from 'opcua';

Do you have a solution for me? Thank you and have a nice day.

mbrohard avatar May 10 '20 17:05 mbrohard

Hi, I still got this error. did you update the npm?

This dependency was not found:                                                                                                                                                                                                                                                                                                              
* opcua in ./node_modules/babel-loader/lib??ref--12-0!./node_modules/ts-loader??ref--12-1!./node_modules/vue-loader/lib??vue-loader-options!./node_modules/unplugin/dist/webpack/loaders/transform.js??ref--14-0!./pages/auth/sign-up/index.vue?vue&type=script&lang=ts&

*/node_modules/opcua/index.d.ts' is not a module.

vahidke avatar Oct 11 '21 14:10 vahidke