Closed adamxy closed 5 years ago
I've not been able to reproduce this issue. It looks from the output that the fs module was not required but in version 0.9.0 is is there. Would you be able to paste the code you are using and I'd be happy to take a closer look.
I did run into a different error when trying to reproduce this and create https://github.com/Qiskit/qiskit-js/pull/83.
import { qiskit } from 'qiskit';
qiskit.algo.random().then(rand => console.log(
JavaScript: ${rand}
));
@danbev When the project is started with 'npm', the error will be reported.
I did run into a different error when trying to reproduce this and create #83.
I have package.json in my project environment dependency.
Below is what I've to reproduce this.
package.json:
{
"name": "qiskit-parser-issue",
"version": "0.0.1",
"license": "Apache-2.0",
"dependencies": {
"qiskit": "^0.9.0"
},
"type": "module"
}
err.js:
import qiskit from 'qiskit';
qiskit.algo.random().then(rand => console.log(`JavaScript: ${rand}`));
Running with Node.js version v12.4.0:
$ npm install
$ node --experimental-modules err.js
(node:21565) ExperimentalWarning: The ESM module loader is experimental.
JavaScript: 0.8533224881075365
npm install
Thank you so much!
Thank you so much!
Glad you were able to get it working! Would you be able to close this issue if you consider this it done?
err.js
export function Qiskit(val) {
qiskit.algo.random().then(val => console.log(JavaScript: ${val}
));
return val
}
b.js import { Qiskit } from './QiskitJs' const const0 = ` IBMQASM 2.0; include "qelib1.inc"; qreg q[1]; creg c[1];
x q[1]; measure q -> c; `; console.log(Qiskit(val))
When I import this err.js file into another file, I still got an error. The error message is as follows TypeError: fs.readFileSync is not a function
@adamxy Can you push this code somewhere, like a github repo or something, so I can see the exact code and package.json you are using?
@adamxy Can you push this code somewhere, like a github repo or something, so I can see the exact code and package.json you are using?
I put this code on my github, you can download it. Thanks https://github.com/adamxy/Qiskit-js-test
@adamxy Thanks! Can you also provide the exact steps/commands to run to reproduce the error you are seeing?
@adamxy Thanks! Can you also provide the exact steps/commands to run to reproduce the error you are seeing?
step1 npm start step2 open chrome browser
This is the output when I run npm start
:
Failed to compile.
./src/index.js
Module not found: Can't resolve 'codemirror/mode/quantum/quantum' in '/Users/danielbevenius/work/machine-learning/Qiskit-js-test/mytest/src'
This does not match the error in this issue, is there some step I've missed?
sorry, please delete the line "import 'codemirror/mode/quantum/quantum'" and update "mode: 'quantum'" to "mode:'python'" in index.js.
@adamxy Thanks for that, I can reproduce it now.
I've taken a quick look but I don't have a quick fix for this and would need to investigate a little. The problem is that this is last day before a four week vacation so I'm afraid I don't have enough time today. I'd be happy to follow up on this when I get back, and will try to take a look later this afternoon before I head off if possible. Sorry about this.
@adamxy Thanks for that, I can reproduce it now.
I've taken a quick look but I don't have a quick fix for this and would need to investigate a little. The problem is that this is last day before a four week vacation so I'm afraid I don't have enough time today. I'd be happy to follow up on this when I get back, and will try to take a look later this afternoon before I head off if possible. Sorry about this.
Thanks for you ,It doesn't matter.
@adamxy Thanks for that, I can reproduce it now.
I've taken a quick look but I don't have a quick fix for this and would need to investigate a little. The problem is that this is last day before a four week vacation so I'm afraid I don't have enough time today. I'd be happy to follow up on this when I get back, and will try to take a look later this afternoon before I head off if possible. Sorry about this.
We are currently developing a quantum computing platform, so we need to integrate this component, but we're not in a hurry, and you could help us solve it when you come back. Thank you and have a nice vacation!
@wuwanlei @adamxy I've taken a look at this now and have created qiskit-webpack-example which allowed me to get passed the issue reported.
Can you take a look and see if it makes sense and let us know if you have any issues (install/build/run instructions can be found in the readme)?
Thank you so much!
Glad you were able to get it working!
@jesusprubio Do you think it would make sense to add qiskit-webpack-example to the qiskit-js repository?
It was a little tricky getting this right the first time and it might save others some time if they can find it and use it as a reference without having to search through the issue to find it.
Yes please, just create a example folder or a new npm package if you think it´s better.
Thank you 😄
react@16.8.6 qiskit@0.9.0
TypeError: fs.readFileSync is not a function (anonymous function) D:/mytest/node_modules/@qiskit/qasm/lib/Parser.js:23 20 | const dbg = utils.dbg(__filename); // const QasmError = require('./QasmError'); 21 | // TODO: Do async? 22 |