I'm trying to use lovell/sharp with Angular universal project, but I have an issue.
I build the server part via webpack and I added sharp to webpack's externals, but I got this error Unexpected character '�' (1:2)
so, I added node-loader to webpack, it builds the project and generates dist folder that contains main.js and sharp-*.node files
but when I run node dist/main I got this error:
Error:
Something went wrong installing the "sharp" module
node-loader:
Error: The specified module could not be found.
//sharp-ac5709806d227d1d966f7f0b76814d78.node
minimal reproduction:
https://github.com/eng-dibo/ng-sharp-issue
1- install dependencies npm install
2- build the server npm run build:server:dev
3- serve node dist/main
to check the webpack configurations, check this file './webpack.server.config.js`
issue solved
the problem is that the webpack plugin webpack-node-externals cannot work with monorepos, in this case it fails to get the correct path of package.json file, results in node modules don't be excluded.
Related
I try to run npm run-script build on my project after downloading git and node and it says that it cannot find module when the module is there in the folder, package.lock file includes react scripts as well. I am new to react and just starting out if anyone has experiences this issue before how did you manage to solve?
image description
I am trying to use google-auth-library with a react app but am getting various errors which seem to indicate missing dependencies. The errors are all in a format similar to this:
Module not found: Error: Can't resolve 'buffer' in '/private/tmp/minimal-example/node_modules/buffer-equal-constant-time'
The error messages include details on how to add a polyfill for the missing dependencies, but even after going through and adding all these polyfills I am unable to use the library. The logs for the development server still show errors for missing files, and the browser console has the following error:
GET http://metadata.google.internal./computeMetadata/v1/instance net::ERR_NAME_NOT_RESOLVED
Steps to reproduce:
Install Node 16.13.2
Create a react app npx create-react-app minimal-example
Enter directory for the created project cd minimal-example
Install google-auth-library npm install google-auth-library --save
Add the following code to ./src/App.js
const {GoogleAuth} = require('google-auth-library');
Start the development server npm start
Observe errors
What am I doing wrong?
I Have the same problem with same google-auth-library package!
This is a problem with using webpack 5 on React scripts=> v5
Have three solutions to resolve:
downgrade react-scripts to version 4.0.3. on package.json file.
Overwrite the config webpack config, but, i will need install react-app-rewired to do this, because react app not have webpack.config on tree app files.
you can eject the script to root folder executing npm run eject, but caution, this action is permanent, more here: https://stackoverflow.com/a/48395890
Some people answered this problem in How to Polyfill node core modules in webpack 5
and https://github.com/facebook/create-react-app/issues/12072
I'm trying to build a react app, which is built from the ground up. I use Yarn as my package manager. Whenever I try to run my node server I'm getting the error "Module not found express". which I did install and is a part of my dependencies.
I found out that the module express is being fetched from a node_modules directory instead of the local app directory, is this the issue?
error description
The module is being fetched from here:
"C:/Users/hp/AppData/Local/Microsoft/TypeScript/4.2/node_modules/#types/express/index"
Thanks in advance :)
EDIT
NPM global screenshots
I was installing node by using the command on cmd npm install and I got following message
enter image description here
Please help me that how I can solve this issue.
npm stands for node package manager which is used to install external packages or npm modules or libraries hosted on NPM. To get started with a Node JS Project you will need index.js and hit npm init, this will initialise your Node JS Project with auto genreated package.json.
Majorly Node JS, React JS or Angular contains following files:
index.js/server.js(Entry File)
package.json (modules/packages/libraries used in project and script can be written to run your project in different envs)
node_modules (which is auto generated and contains all installed modules listed in package.json)
According to your error message you don't have a package.json file so you need to initialize npm before installing node in your directory.
Initialize it with npm init.
Npm documentation
Step 1- First install Node from https://nodejs.org/en/download/.
Step 2- Now go to your project file cd project.
Step 3- Type the command npm init in console.
Step 5- Now you can see package.json file in your project.
Finish- Now you can install any package by using "npm install packageName" command.
I am trying to use firebase-admin npm module in a Netlify cloud function. By default netlify-lambda packages the functions with Webpack, which breaks firebase-admin as it's not compatible with Webpack.
I tried using the alternate "zip n ship" method but even that doesn't works. From the error, it seems the node_modules generated on my machine are not working correctly on the machine where the function is deployed. Here is the error:
Error: The gRPC binary module was not installed. This may be fixed by running "npm rebuild"
Original error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'
Anyone who has made this work?
you can use Webpack to generate new package.json file into the lambda directory and install its dependencies, then run netlify-lambda as this tutorial shows firebase-admin-with-netlify-lambda