npm gives error when installing module not specified by me - node.js

I am trying to install the modules needed by my application using
npm install
When I do this, I get the following error:
npm ERR! Error: No compatible version found: gulp-util#'^3.0.0'
npm ERR! Valid install targets:
npm ERR! ["0.0.1","1.0.0","1.1.0","1.1.1","1.2.0","1.3.0","2.0.0","2.1.1","2.1.2","2.1.3","2.1.4","2.2.0","2.2.1","2.2.2","2.2.3","2.2.5","2.2.6","2.2.7","2.2.8","2.2.9","2.
2.10","2.2.11","2.2.12","2.2.13","2.2.14","2.2.15","2.2.16","2.2.17","2.2.18","2.2.19","2.2.20","3.0.0","3.0.1","3.0.2","3.0.3","3.0.4","3.0.5","3.0.6"]
However, I never require this module into my project.
I'm assuming it's an issue internal of npm or node.
Furthermore, also strange is that when I run
npm list -g
I get the following output rather than seeing the versions of npm which are installed.
├── node#0.0.0
My package.json file is:
{
"name": "myProject",
"version": "0.0.1",
"dependencies": {},
"scripts": {
"test": "gulp test"
},
"devDependencies": {
"browserify": ">=9.0.7",
"gulp": ">=3.8.11",
"gulp-concat": ">=2.6.0",
"gulp-html-replace": ">=1.5.1",
"gulp-react": ">=3.0.1",
"gulp-streamify": ">=1.0.2",
"gulp-uglify": ">=1.2.0",
"gulp-util": ">=3.0.6",
"reactify": ">=1.1.1",
"vinyl-source-stream": ">=1.1.0"
},
"engines": {
"node": ">=0.10.0"
}
}

Your version of npm is so old that it doesn't support version ranges specified using ^. You are not using that syntax but it is quite likely one of the modules you are specifying is using that syntax for it's dependencies, and so when it tries to run npm install gulp-util#'^3.0.0' it throws that error.
If you update your npm either by updating node or by installing the latest npm with npm install -g npm then you should be able to proceed.

Related

Cannot read property 'createSnapshot' of undefined

Since I used Electron forge webpack plugin, when I execute npm start, it will cause an error after step Compiling Preload Scripts. It says the error is inside Forge.
I check it out, it's an error in file watcher api, that mainCompilation.fileSystemInfo is undefined, so it cannot read prop createSnapShot function.
What should I do to resolve this error and start my app?
Logs:
> datapack-planet#0.0.0 start D:\program\datapack-planet
> electron-forge start
√ Checking your system
√ Locating Application
You have set packagerConfig.ignore, the Electron Forge webpack plugin normally sets this automatically.
Your packaged app may be larger than expected if you dont ignore everything other than the '.webpack' folder
√ Preparing native dependencies
√ Compiling Main Process Code
√ Launch Dev Servers
√ Compiling Preload Scripts
An unhandled rejection has occurred inside Forge:
TypeError: Cannot read property 'createSnapshot' of undefined
at D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\webpack5\file-watcher-api.js:13:36
at new Promise (<anonymous>)
at Object.createSnapshot (D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\webpack5\file-watcher-api.js:12:10)
at D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\cached-child-compiler.js:219:35
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Electron Forge was terminated. Location:
{}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! datapack-planet#0.0.0 start: `electron-forge start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the datapack-planet#0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dell\AppData\Roaming\npm-cache\_logs\2021-01-22T04_33_47_591Z-debug.log
My package.json (NOT ALL, ONLY IMPORTANT DATA):
{
"main": "./.webpack/main",
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"#electron-forge/plugin-webpack": "^6.0.0-beta.54",
"#marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
"#types/jquery": "^3.5.5",
"#types/node": "^14.14.22",
"electron": "^11.1.1",
"fork-ts-checker-webpack-plugin": "^6.1.0",
"html-loader": "^1.3.2",
"jquery": "^3.5.1",
"less": "^4.1.0",
"less-loader": "^7.2.1",
"node-loader": "^1.0.2",
"ts-loader": "^8.0.14",
"typescript": "^4.1.3",
"webpack": "^5.16.0",
"webpack-cli": "^4.4.0"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"jquery": "^3.5.1"
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
},
"config": {
"forge": {
"packagerConfig": {
"ignore": [
"\\.(idea|git)",
"config\\.json",
"[A-Z]",
"md$"
]
},
"makers": [
// There is some auto-generated settings, I didn't changed it.
// So I skip those configs.
],
"plugins": [
[
"#electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.ts",
"name": "main_window"
}
]
}
}
]
]
}
}
}
Resolve: I restart the project. Maybe I missed some dependencies. I am copying from the template, so the bug may should be occurred as expected.
My work around was to remove node_modules and package-lock.json, and then run
npm install --legacy-peer-deps
There is an issue with very modern versions of npm and this gives you the legacy install rules which seem to work
I had the same issue which was resolved after checking and correcting the installed versions.
Run npm ls webpack to show the peer dependencies missing. This will help you figure out the right version required in your app.
Change to required version, save the package.json file.
Delete both package-lock.json and the node_modules folder.
Run npm install.
Run the script again.
I had this same issue and it seemed to be a compatibility issue with npm7 and plugin-webpack.
There are a few solutions, but the easiest for me was to simply use yarn instead of npm.
delete node_modules/
delete package-lock.json
run yarn install
run yarn start
This worked for me, let me know if this helps!
its due to mismatch of your webpack versions, just check npm list webpack, you will be able to see something like unmet dependecies.Just create peerDependencies and add webpack into it or can remove webpack inteself.Check your ts-loader version too,it should be less than 9.see the magic :)
run npm install or yarn inside the project, to install project's dependencies

Cant build app using npx grunt on Windows

On Windows 8.1 installed Node.js 12.16.
First I run "npm install grunt" in a root directory of project.
Installation passed succesfully, however with the following warnings:
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion#
1, but npm-shrinkwrap.json was generated for lockfileVersion#0. I'll try to do m
y best with it!
npm WARN deprecated minimatch#0.2.14: Please update to minimatch 3.0.2 or higher
to avoid a RegExp DoS issue
npm WARN deprecated coffee-script#1.3.3: CoffeeScript on NPM has moved to "coffe
escript" (no hyphen)
npm WARN deprecated minimatch#0.3.0: Please update to minimatch 3.0.2 or higher
to avoid a RegExp DoS issue
npm WARN platform-web#0.0.1 No repository field.
npm WARN platform-web#0.0.1 No license field.
npm WARN The package time-grunt is included as both a dev and production depende
ncy.
npm WARN The package object-assign is included as both a dev and production depe
ndency.
+ grunt#0.4.5
added 38 packages from 47 contributors and audited 54 packages in 3.026s
found 25 vulnerabilities (5 low, 6 moderate, 14 high)
run `npm audit fix` to fix them, or `npm audit` for details
Root directory containts grunt-folder (root_dir/grunt), in which Gruntfile.js and package.json files are located.
And this grunt-folder containts other grunt-folder (root_dir/grunt/grunt). This second grunt containts some js-files.
Then in "root_dir/grunt" I run "npx grunt". But the build aborted with the following log:
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-includes" not found. Is it installed?
>> Local Npm module "grunt-text-replace" not found. Is it installed?
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-contrib-cssmin" not found. Is it installed?
>> Local Npm module "grunt-file-creator" not found. Is it installed?
>> Local Npm module "grunt-war" not found. Is it installed?
>> Local Npm module "nexus-deployer" not found. Is it installed?
Warning: Task "clean:all" not found. Use --force to continue.
Aborted due to warnings.
package.json is
{
"name": "platform-web",
"version": "0.0.1",
"description": "Platform",
"devDependencies": {
"archiver": "^0.12.0",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-cssmin": "0.12.3",
"grunt-contrib-uglify": "^0.6.0",
"grunt-file-creator": "^0.1.3",
"grunt-includes": "^0.5.1",
"grunt-text-replace": "^0.4.0",
"grunt-war": "^0.5.1",
"nexus-deployer": "^0.1.8",
"object-assign": "^4.0.1",
"time-grunt": "^1.1.0"
},
"dependencies": {
"time-grunt": "^1.0.0",
"object-assign": "^4.0.1"
}
}
What am I doing wrong?
p.s.: root-folder is:
Following is only needed for older versions of grunt. New one install the bunstubbs correctly so you can still install grunt via npm and not globally.
Install grunt-cli. This will correctly pick up whichever version of grunt the project is running and execute it.
npm install grunt-cli --save-dev
In the package.json change dev script to
"scripts": {
"start": "npx grunt-cli"
}
then run
npm run start

ENOENT: no such file or directory when running npm install command

When I run npm install, I getting the following error,
npm WARN tar ENOENT: no such file or directory, open 'D:\Live Project\insyte-mobile\insyte-mobile\node_modules.staging\core-js-c9f4d03d\library\fn\symbol\unscopables.js'
Here is a screen shoot of the error
:
Here is my package.json
{
"name": "tonight-mobile",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "~27.0.0",
"react-test-renderer": "16.3.1"
},
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"eject": "expo eject",
"initial-android": "npm install && npm run android",
"initial-ios": "npm install && npm run ios",
"android": "expo start --android",
"ios": "expo start --ios",
"test": "jest",
"postinstall": "rm ./node_modules/react-native/local-cli/core/__fixtures__/files/package.json"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"axios": "^0.18.0",
"expo": "^32.0.0",
"expo-image-picker": "^5.0.2",
"firebase": "^5.7.1",
"firebase-admin": "^8.5.0",
"firebase-functions": "^3.2.0",
"react": "16.5.0",
"react-native": "https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz",
"react-native-firebase": "^5.1.1",
"react-native-image-crop-picker": "^0.21.3",
"react-native-image-picker-form": "^0.2.5",
"react-native-maps": "^0.21.0",
"react-native-responsive-image": "^2.3.1",
"react-native-swiper": "^1.5.14",
"react-native-vector-icons": "^5.0.0",
"react-navigation": "^2.13.0",
"react-navigation-tabs": "^1.0.2",
"react-redux": "^5.0.7",
"redux": "^4.0.0",
"redux-persist": "^5.10.0",
"redux-persist-filesystem-storage": "^1.3.2",
"redux-thunk": "^2.3.0",
"tcomb-form-native": "^0.6.20"
}
}
above is the package.json file.
I have also used another code of this project, but this time I'm getting following error :
First delete the package-lock.json and then try npm install
Delete node_modules folder and package-lock.json, then run npm install
All you need to do is
Open a terminal in your pc's root and run this command:
killall node
Before restart the new metro bundler please reinstall the dependencies on yarn or npm :
npm i OR yarn
Also the article: ENOENT: no such file
Follow this step:
Delete node_modules folder and package-lock.json file
Run this command:
npm cache clean -force
Then run this command:
npm install (if the issue is not yet fixed try the following 4th step.)
Run this command npm install -g npm,then npm install
Finally run this command: npm start
Please check your current working directory. if you have created project using
npx react-native init demo
then navigate inside project from terminal using
cd demo
npm install
will install all npm modules and you can also check installed packages in the directory: demo/node_modules
also if project is expo base then
run expo eject to eject from expo
Check the node version, if the application was build using an older node version then you can downgrade your local environment node version using NVM (node version manager).
My simple solution for this error:
"npm WARN tar ENOENT:no such file or directory
Not only for ENOENT if all files in npm modules shows this kinds of error.
Go to your command prompt
Check for npm version(npm -v)
If its giving a version then type command npm init and click on enter for whatever it asks
After completing all the steps and then again try to create one angular project. It will be created without any errors in node modules.
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path E:\Projects\package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'E:\Projects\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
Solution ==> Check the root directory you might be outside the root directory or in wrong folder path has been opened
I suspect you do not have git installed on your computer. This is particularly true if you are getting this error at the bottom of your log:
npm ERR! syscall spawn git
If so, then you need to install git from here: https://git-scm.com/downloads.
I had the same problem as you, and once I installed git, the problem went away.
Do you have a package.json file in the folder ?*
To run npm install you need to have a package.json file.

Google Cloud: Create A Simple Application With the API samples npm install failed

Following the instruction from here, https://cloud.google.com/bigquery/create-simple-app-api
cd to the samples folder
https://github.com/googleapis/nodejs-bigquery/tree/master/samples
The package.json is
https://github.com/googleapis/nodejs-bigquery/blob/master/samples/package.json
{
"name": "nodejs-docs-samples-bigquery",
"version": "0.0.1",
"private": true,
"license": "Apache-2.0",
"author": "Google LLC",
"repository": "googleapis/nodejs-bigquery",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "repo-tools test run --cmd npm -- run cover",
"ava": "ava -T 3m --verbose test/*.test.js system-test/*.test.js",
"cover": "nyc --reporter=lcov --cache ava -T 3m --verbose test/*.test.js system-test/*.test.js && nyc report"
},
"dependencies": {
"#google-cloud/bigquery": "1.2.0",
"#google-cloud/storage": "1.5.1",
"yargs": "10.0.3"
},
"devDependencies": {
"#google-cloud/nodejs-repo-tools": "2.1.3",
"ava": "0.24.0",
"nyc": "11.3.0",
"proxyquire": "1.8.0",
"sinon": "4.1.3",
"uuid": "3.1.0"
}
}
I run
npm install
I get errors
Home-iMac:samples user1$ npm install
npm WARN #google-cloud/bigquery#1.2.0 had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.
npm ERR! path /Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#google-cloud/bigquery-78ee5bef/node_modules/#sindresorhus/is' -> '/Users/user1/project1/gcp/nodejs/bigquery_api/nodejs-bigquery-test/samples/node_modules/.staging/#sindresorhus/is-79439449'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/user1/.npm/_logs/2018-04-27T19_38_14_391Z-debug.log
To fix the error, a hack solution is instead of using the package.json to install, I have to run this manually first
npm install --save #google-cloud/bigquery
Then I can run
npm install
again. This time, it will finish without problem.
But I would like to be able to just simply using package.json, using npm install only to install the packages.
I changed the package.json
From
"#google-cloud/bigquery": "1.2.0",
to
"#google-cloud/bigquery": "^1.2.0",
It still does not work.
Thanks!
#Tim - Thanks for the request to update, #google/bigquery 1.3.0 is being used for the example. The download link to the GitHub site was updated, but the sample code on the page itself is not updated.

Npm rebuild node-sass fails

I have an old project that has a grunt as build tool. I have installed the project dependencies and grunt cli. This is the package.json file:
{
"name": "",
"version": "0.0.1",
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"grunt-sass": "^1.0.0",
"node-sass": "^3.3.3"
}
}
On trying to run grunt I got an error that I need to run npm rebuild node-sass, but I got a new error then:
npm ERR! Failed at the node-sass#3.4.2 postinstall script 'node
scripts/build.js'. npm ERR! Make sure you have the latest version of
node.js and npm installed. npm ERR! If you do, this is most likely a
problem with the node-sass package, npm ERR! not with npm itself.
I have even tried with running the command with the --force flag.
But that didn't work either, how can I fix this?

Resources