Npm rebuild node-sass fails - node.js

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?

Related

How to resolve peer dependency conflict

Thanks for reading.
After testing some changes in my local dev environment and having no issues, I promoted the changes to my test environment hosted on AWS Amplify, and the build was failing with the following error:
2022-11-28T19:47:50.604Z [WARNING]: ERR! ERESOLVE could not resolve
npm ERR!
npm
2022-11-28T19:47:50.605Z [WARNING]: ERR! While resolving: styles#0.2.1
npm ERR! Found: assemble#0.24.3
npm ERR! node_modules/assemble
npm ERR!
2022-11-28T19:47:50.605Z [WARNING]: assemble#"^0.24.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer assemble#"~0.3.11" from styles#0.2.1
npm ERR! node_modules/styles
npm ERR! styles#"^0.2.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: assemble#0.3.83
npm ERR! node_modules/assemble
npm ERR! peer assemble#"~0.3.11" from styles#0.2.1
npm ERR! node_modules/styles
npm ERR! styles#"^0.2.1" from the root project
npm ERR!
npm ERR!
2022-11-28T19:47:50.605Z [WARNING]: Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
Here are the two dependencies mentioned in the above error, in the package.json file:
"assemble": "^0.24.3",
"styles": "^0.2.1"
Here are the two dependencies mentioned above, in the package-lock file:
"node_modules/styles": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/styles/-/styles-0.2.1.tgz",
"integrity": "sha1-hJJ7pEf6pvJJ7NIK3wu4X606UUE=",
"dependencies": {
"less": "\~1.4.0"
},
"engines": {
"node": "\>= 0.8.0"
},
"peerDependencies": {
"assemble": "\~0.3.11",
"grunt": "\~0.4.0"
}
},
"node_modules/assemble": {
"version": "0.24.3",
"resolved": "https://registry.npmjs.org/assemble/-/assemble-0.24.3.tgz",
"integrity": "sha1-lSp3S3iAl6TW9Iw6QrpW9ouNZS8=",
"dependencies": {
"assemble-core": "^0.31.0",
"assemble-loader": "^1.0.5",
"base-argv": "^0.5.0",
"base-cli-process": "^0.1.19",
"base-config": "^0.5.2",
"base-questions": "^0.9.1",
"base-runtimes": "^0.2.0",
"cross-spawn": "^5.1.0",
"engine-handlebars": "^0.8.2",
"expand-front-matter": "^1.0.0",
"export-files": "^2.1.1",
"global-modules": "^0.2.3",
"is-valid-app": "^0.3.0",
"lazy-cache": "^2.0.2",
"log-utils": "^0.2.1",
"minimist": "^1.2.0",
"parser-front-matter": "^1.6.3",
"resolve-dir": "^1.0.0"
},
"bin": {
"assemble": "bin/cli.js"
},
"engines": {
"node": "\>=4.0"
}
},
I tried running the build with --force, and --legacy-peer-deps, but neither of the two dependencies mentioned above (assemble, and styles) are affected by either operation, and I still have the same issue.
I've tried installing the version of assemble to version 0.3.11 (as listed as the peerDependecy of styles), and again the build in my local environment works, but after promoting to my test environment on AWS Amplify, the build fails with the following errors:
2022-11-28T19:38:40.756Z [WARNING]: npm ERR!
2022-11-28T19:38:40.756Z [WARNING]: code EUSAGE
2022-11-28T19:38:40.760Z [WARNING]: npm
2022-11-28T19:38:40.760Z [WARNING]: ERR!
npm ERR! `npm ci` can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with `npm install` before continuing.
npm ERR!
npm ERR! Missing: immutable#4.1.0 from lock file
npm ERR! Missing: seamless-immutable#7.1.4 from lock file
npm ERR! Missing: typescript#4.9.3 from lock file
I also uninstalled assemble and styles, but ran into the same error when trying to build the test environment.
Additionally, I went and looked at my commit history, and the package.json and package-lock.json files haven't been changed in months, and I've had many successful builds since they were last modified, which adds to my confusion of where this problem came from.
Further info:
Local Dev environment is using node v16.13.1 and npm v8.1.2, and Amplify build image (default image) just specifies in the build logs that its using Node version 16
Uninstalling both dependencies and then running npm update resolved my issues

How do I solve npm install issue after deleting node_modules

I am trying to clean out my react-native project's package to do a clean npm install on a MacOS based system (my windows system for Android development has no issues in cleaning up package versions).
I started seeing errors in the npm instals complaining version differences betwces are not compatible and list differences between versions of each package in "rook project" and node_modules/ directory.
I do the usual fix by removing package-lock.json, delete the node_modules directory and re-run npm install. from my project folder. It immediately made the same error complaints. The problem is this, there is no node_modules in my project folder as I deleted it. And it did not create a new node_modules directory.
Given this issue, how do I debug this and fix it? Questions I'd like to find out:
how do I tell npm to tell me what it thinks root project value is (full path)?
How to tell npm to tell me where the full path to the node_modules directory it seems to see?
Finally, how do I force npm to do the right thing and focus my my project's collaterals and not look outside the project folder as it appears to be doing?
Some of my thoughts. I don't understand why it is making a package cersion comparison between root project and node_modules?
Seems that nodde and npm are doing different things in MacOS environment than in my windows system environment -- I don't understand this.
Anyone here can help me understand what is going on and how to solve it?
The Error output here:
thomas#Presonus americanaradio % npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: AmericanaRadio#0.0.2
npm ERR! Found: react#16.14.0
npm ERR! node_modules/react
npm ERR! react#"^16.13.1" from the root project
npm ERR! peer react#"^16.8" from
#react-native-community/async-storage#1.12.1
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.12.1" from the
root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"17.0.2" from react-native#0.66.4
npm ERR! node_modules/react-native
npm ERR! react-native#"^0.66.3" from the root project
npm ERR! peer react-native#">=0.59" from
#react-native-community/async-storage#1.12.1
npm ERR! node_modules/#react-native-community/async-storage
npm ERR! #react-native-community/async-storage#"^1.12.1" from the
root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency
resolution.
npm ERR!
npm ERR! See /Users/thomas/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/thomas/.npm/_logs/2021-12-10T15_47_02_669Z-debug.log
thomas#Presonus americanaradio %
The package.json content here:
{END)
"name": "AmericanaRadio",
"version": "0.0.2",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"#react-native-community/async-storage": "^1.12.1",
"#react-native-community/checkbox": "^0.5.2",
"#react-native-community/masked-view": "^0.1.10",
"#react-native-community/slider": "^3.0.3",
"node-fetch": "^2.6.1",
"react": "^16.13.1",
"react-native": "^0.66.3",
"react-native-background-timer": "^2.4.1",
"react-native-elements": "^3.4.2",
"react-native-gesture-handler": "^1.9.0",
"react-native-keyboard-aware-scroll-view": "^0.9.5",
"react-native-reanimated": "^2.2.4",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "^2.15.2",
"react-native-simple-survey": "^3.1.2",
"react-native-swift": "^1.2.1",
"react-native-vector-icons": "^8.0.0",
"react-native-version-check": "^3.4.2",
"react-native-version-info": "^1.1.0",
"react-native-webview": "^11.3.1",
"react-navigation": "^4.4.3",
"react-navigation-drawer": "^2.6.0",
"react-navigation-stack": "^2.10.2",
"react-usestateref": "^1.0.8",
"socket.io-client": "^4.4.0"
},
"devDependencies": {
"#babel/core": "^7.12.10",
"#babel/runtime": "^7.12.5",
"#react-native-community/eslint-config": "^2.0.0",
"babel-jest": "^26.6.3",
"eslint": "^7.18.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.64.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
~
(END)
As noted in my description, the node_modules directory was deleted and running npm install failed and did not create a nodes_modules directory. So the error messages are confusing as I have no packages in my project directory (americanaradio).
Thank you for taking a look at this and hopefully a solution can come out of ths.
First check what library is giving you an error and try to reinstall or update that version . Try deleting node modules also . Then do npm install.

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 install Errors on mac 10.7.5

I am learning mongodb and as part of my learning process, I installed mongodb, nodejs and npm. When I execute the instruction npm install, this is the error I get:
me$ npm install
npm WARN package.json # No repository field.
npm ERR! Darwin 11.4.2
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v4.2.2
npm ERR! npm v2.14.7
npm ERR! version not found: mongodb#3.2.1
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/me/Sites/mongodb/chapter1/npm-debug.log
This is the package.json:
{
"scripts": {
"test": "gulp test",
"watch": "gulp watch"
},
"dependencies": {
"async": "0.9.0",
"mongodb": "3.2.1"
},
"devDependencies": {
"gulp": "3.8.11",
"gulp-mocha": "2.0.1",
"mocha": "2.2.4"
}
}
I created a database called mongodb so it can see it but, I don't know what is wrong. I read the npm install errors" but nothing points to the similar error so I can solve it myself. Please, help !!
npm ERR! version not found: mongodb#3.2.1
It means the version 3.2.1 of the mongodb package doesn't exist (see https://www.npmjs.com/package/mongodb - currently, last version in 2.1.4).
Just fix the version number in your package.json from:
"dependencies": {
"async": "0.9.0",
"mongodb": "3.2.1"
},
to
"dependencies": {
"async": "0.9.0",
"mongodb": "^2.1.4"
},
Then re-run npm install

npm gives error when installing module not specified by me

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.

Resources