HBM / opcua

TypeScript / JavaScript OPC UA client for the browser
MIT License
42 stars 5 forks source link

NPM module cannot be imported #2

Open scranen opened 4 years ago

scranen commented 4 years ago

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 opcua-plain@1.0.0 No description
npm WARN opcua-plain@1.0.0 No repository field.

+ opcua@1.0.0
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
project@1.0.0 (project-dir)
└── opcua@1.0.0 
zemirco commented 4 years ago

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

scranen commented 4 years ago

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.

mbrohard commented 4 years ago

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.

vahidke commented 3 years ago

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.