Closed Anshul0305 closed 5 years ago
my npm version is 5.6.0
and node version is v10.2.1
Just updated npm to latest version 6.9.0
still getting the same error.
Greetings! I can't reproduce this one. Nodejs 10.2.1 is very old. Can you try 10.15.2
?
Also - can you share the full code example you're using?
And your operating system?
What environment are you trying to run this in? Regular server side app? Webpacked? React app?
OK I installed latest version of node v11.13.0
Removed node_modules
folder and done npm install
again
However, still seeing the exactly same error.
Module not found: Can't resolve 'http2' in '/Users/Anshul/Documents/Anshul/AWT/ReactJS/react-chat-ui/node_modules/@grpc/grpc-js/build/src'
Here are the environment details Mac OS High Sierra 10.13
I have created a chatbot app using Create React App and then trying to integrate it with Dialogflow.
Here is the code:
import React, { Component } from 'react';
import './App.css';
import './scripts';
import Messages from "./Messages";
import Input from "./Input";
const dialogflow = require('./dialogflow');
class App extends Component {
state = {
messages: [
{
id: 0,
text: "This is a test message!",
member: {
color: "blue",
username: "Chatbot"
}
}
],
member: {
id: "Chatbot",
username: randomName(),
color: randomColor()
}
}
onSendMessage = (message) => {
dialogflow.getResponse(message)
.then((response) => {
const messages = this.state.messages;
messages.push({
id: this.state.messages.length,
text: message,
member: this.state.member
})
messages.push({
id: this.state.messages.length,
text: response,
member: {
username: "Chatbot",
color: "blue"
}
})
this.setState({messages: messages})
});
}
render() {
return (
<div className="App">
<div className="App-header">
<h1>My Chat App</h1>
</div>
<Messages
messages={this.state.messages}
currentMember={this.state.member}
/>
<Input
onSendMessage={this.onSendMessage}
/>
</div>
);
}
}
export default App;
Can see a similar problem here: https://github.com/grpc/grpc-node/issues/610
I did npm install http2
And now seeing this error:
Compiled with warnings.
./node_modules/http2/lib/protocol/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
./node_modules/grpc/src/grpc_extension.js
Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js
Critical dependency: the request of a dependency is an expression
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
It looks like create-react-app
is the common bond here.
not to pile on (but I'm piling on) could you try deleting a package-lock.json
before the installation? (if you haven't already).
OK deleted the package-lock.json and node_modules and then did npm install but still getting the same error
Compiled with warnings.
./node_modules/http2/lib/protocol/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
./node_modules/grpc/src/grpc_extension.js
Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/pre-binding.js
Critical dependency: the request of a dependency is an expression
./node_modules/grpc/node_modules/node-pre-gyp/lib/util/versioning.js
Critical dependency: the request of a dependency is an expression
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
@Anshul0305 aha! I should have read a bit closer, because of the node-pre-gyp
dependency, I don't believe you will be able to include this in the frontend react component -- I believe it might be webpack generating these error messages.
I think your best bet at this time would be running a service that the react application interacts with, which in turn runs dialogflow
.
Oh got it. Actually, that's what I was thinking. Thanks for your help.
@Anshul0305 I'm closing this issue, but it does continue to underscore how much we'd love to be able to drop the node-pre-gyp
dependency eventually, which is already on our minds 👍
Benjamin E. Coe Cloud You please see this how to fix it Thank you in Advance :)
./node_modules/@grpc/grpc-js/build/src/server.js Module not found: Can't resolve 'http2' in 'E:\ReactPubsub\PubSub\publisher_app\node_modules\@grpc\grpc-js\build\src'
Hello everyone getting error in npm googleapis package Module not found: Can't resolve 'http2' in ./node_modules/googleapis-common/build/src/http2.js
as i have installed npm i googleapis and trying installing http2 but again it is giving error using in reactjs
Running into the same issue:
Module not found: Can't resolve 'http2' in 'node_modules/googleapis-common/build/src'
The aforementioned issue doesn't seem to have any resolution. Is there any update on the timeline of supporting this with an app bootstrapped by create-react-app
?
Additionally, if I try npm i http2
, then the npm start
output is
Compiled with warnings.
./node_modules/http2/lib/protocol/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
and the app fails during runtime (in browser) with Error: Cannot find module './framer'
@SomervilleTom I deleted your comment because it violated our code of conduct: https://github.com/googleapis/nodejs-dialogflow/blob/master/CODE_OF_CONDUCT.md
If you'd like to file a new issue using your best kind words, along with specifics of what you're running into, we'd be happy to take a look.
Let me try again, with more restraint. It is disappointing to find this issue marked as "closed" when "shivasuri" and at least four other people (including yours truly) are reporting this failure within the past month. I hope that that "closed" status will be revisited.
My specific experience is exactly the same as reported above by "shivasuri". I'm running CentOS 7 on an AWS EC2 instance. I develop using Visual Studio Code (VSC) on a local robust Win10 Pro system using the "RemoteSSH" extension to connect to the target system. I keep an SSH connection from the local host to the remote target system at all times, and I forward various ports including 3000, 3001, and so on from the target system back to the local host. I use a local up-to-date Chrome browser, and I use the "Debugging in Chrome" extension in VSC.
I've installed googleapi following the guidance from the documentation:
$ npm install googleapis --save
$ npm install google-auth-library --save
When I attempt to start the react app, I see the same complaints reported above:
Module not found: Can't resolve 'http2' in 'node_modules/googleapis-common/build/src'
When I install http2 from the command line:
$npm i http2
I get the same failure reported above:
Compiled with warnings.
./node_modules/http2/lib/protocol/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
It would be very helpful if a workaround (with enough detail for an npm/react newbie to follow) could be posted here, especially if this issue is to remain closed. It prevents me from using googleapis, and that in turn is blocking my ability to successfully continue development of my current project (which requires using the youtube v3 search api).
FWIW, I do not need http2 functionality or behavior.
Awesome - thanks for reposting :) Could I trouble you to take this exact comment, and create a new issue? When folks start commenting in the same issue, it has a funny way of confusing multiple issues, and making the thread a lot harder to follow. I would create it for you, but I want to make sure you get notified and such when we post. I am going to go ahead and lock this thread from here on out so others don't saunter in, and end up with us missing it. Thank you!
When installing Dialogflow npm module, I am getting this error
Module not found: Can't resolve 'http2' in '/node_modules/@grpc/grpc-js/build/src'
When I add this to my code
const dialogflow = require('dialogflow');
Then I get above error:
When I remove
const dialogflow = require('dialogflow')
then the code works fine.