Error When Installing node-sass for Vue JS Project - node-modules

When running an 'npm install' on a VueJS project I run into the following error:
error: no matching constructor for initialization of 'v8::String::Utf8Value'
v8::String::Utf8Value string(value);
^ ~~~~~
/Users/webdevwolf/.node-gyp/12.14.1/include/node/v8.h:3046:5: note: candidate constructor not viable: no known conversion from 'v8::Local<v8::Value>' to
'const v8::String::Utf8Value' for 1st argument
Utf8Value(const Utf8Value&) = delete;
^
/Users/webdevwolf/.node-gyp/12.14.1/include/node/v8.h:3039:5: note: candidate constructor not viable: requires 2 arguments, but 1 was provided
Utf8Value(Isolate* isolate, Local<v8::Value> obj);
^
1 error generated.
make: *** [Release/obj.target/binding/src/create_string.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/node-sass/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:223:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.2.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/local/lib/node_modules/node-sass
gyp ERR! node -v v12.14.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.11.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.11.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
To get round this I've tried the following:
Updating Node to the latest stable version
Updating sass
Running an install for the 4.11.0 version of Sass
I'm getting super frustrated with it now and I'm not even sure what this error even means - does anyone have any idea on how to fix this at all?

I was having a similar issue with Node version 16 and Vue 3.
The problem seems to be node-sass related and is incompatible with node version 16 or something. Other people have mentioned using Node 14 with no problems.
This error would happen even when I ran vue create app clicked on the manual configuration option and choose to have node-sass setup / configured. It would start downloading but freeze when it came time to download node-saas and exit with an error.
My solution was to download Vue 3 without the node-sass option and then after it was done installing, npm i -D sass sass-loader#7 instead of npm i -D node-sass
you also need to add this to you vue.config.js file in the root directory.
// vue.config.js
module.exports = {
css: {
loaderOptions: {
sass: {
implementation: require('sass'),
},
},
}
}
Thats all you should need to get scss running.
Just dont forget to add the lang="scss" attribute the the script tags.
<style lang="scss">
.....
</style>
I found my solution from this article:
https://www.priestch.com/replace-node-sass-with-dart-sass-in-vue-cli3-based-project/

I fixed this with -
npm install node-sass
If that fails then
delete your node_modules folder
npm install
npm install node-sass
Sometimes when I come back to an old vue project after using the latest version of sass I get this error. And cleaning out the modules and re-installing the correct version for my project always seems to fix it.

If you are struggling with
node 16.13.2
#vue/cli 4.5.15
vue create to create a new Vue 3 project
and you want to use node-sass but you keep having errors
Don't add a css preprocessor to your project with vue create
Create your project with vue create then use this commands (and exactly this commands)
npm i -D sass-loader#^10.0.0
npm i node-sass#^6.0.1 --unsafe-perm

There is an issue with vue and nodejs 16 issued here. node-sass (4.11) bundled with vue-cli 4.5 is incompatible with nodejs 16. What I did:
upgrade the vue-cli to the latest (currently 5.0.4)
create a new project (in my case with vue ui)
EDIT: delete old node_modules folder
compare my old package.json with the new and took over the vue specific imports
compare the configuration files for vue, typescript, jest, cypress, eslint (or whatever you use)
EDIT: Backup or commit before executing next command, because it will change your config files. Then run vue add #vue/cli-plugin-eslint (npm install will fail)
NOT absolutely necessary: start npm-gui and updated all packages to compatible versions (do not know how to do this without npm-gui) Caution: compatible is not always newer.
Here is the generated package.json for the project (TS, ESLint, Jest, Cypress, Sass, Babel, Vuex) without Router:
{
"name": "vuenew",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:e2e": "vue-cli-service test:e2e",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.8.3",
"register-service-worker": "^1.7.2",
"vue": "^3.2.13",
"vuex": "^4.0.0"
},
"devDependencies": {
"#types/jest": "^27.0.1",
"#typescript-eslint/eslint-plugin": "^5.4.0",
"#typescript-eslint/parser": "^5.4.0",
"#vue/cli-plugin-babel": "~5.0.0",
"#vue/cli-plugin-e2e-cypress": "~5.0.0",
"#vue/cli-plugin-eslint": "~5.0.0",
"#vue/cli-plugin-pwa": "~5.0.0",
"#vue/cli-plugin-typescript": "~5.0.0",
"#vue/cli-plugin-unit-jest": "~5.0.0",
"#vue/cli-plugin-vuex": "~5.0.0",
"#vue/cli-service": "~5.0.0",
"#vue/eslint-config-standard": "^6.1.0",
"#vue/eslint-config-typescript": "^9.1.0",
"#vue/test-utils": "^2.0.0-0",
"#vue/vue3-jest": "^27.0.0-alpha.1",
"babel-jest": "^27.0.6",
"cypress": "^8.3.0",
"eslint": "^7.32.0",
"eslint-plugin-import": "^2.25.3",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-promise": "^5.1.0",
"eslint-plugin-vue": "^8.0.3",
"jest": "^27.0.5",
"sass": "^1.32.7",
"sass-loader": "^12.0.0",
"ts-jest": "^27.0.4",
"typescript": "~4.5.5"
}
}
EDIT2: We found some errors, which seems to be some sort of vue3 <-> TS thing.
after upgrading vue-cli to 5.0.4, tsc reports an error in a .ts (merge.ts from vue-splide) file inside node_modules. Switching back to TS 4.5.5 solved this issue.
EDIT:
In my project, I can upgrade:
typescript to 4.6.3 (current latest)
#vue/eslint-config-typescript to 10.0.0 (current latest)

Related

fsevents not accessible from jest-haste-map

When i deploy my app from github.com to heroku. I get the following message error: fsevents not accessible from jest-haste-map.
Could you help me solve this issue.
This is my package.json
{
"name": "app-clean",
"version": "0.1.0",
"private": true,
"main": "index.js",
"dependencies": {
"#reduxjs/toolkit": "^1.6.0",
"#testing-library/jest-dom": "^5.11.4",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"bootstrap": "^5.0.1",
"bootstrap-icons": "^1.5.0",
"json-server": "^0.16.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-scripts": "4.0.3",
"web-vitals": "^1.0.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"server": "json-server db.json -p 5000 -w -d 0"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Thanks
So it seems that there are some internal dependencies that depend on the fsevents module. The general consensus seems to be to make this dependency optional, which should fix your problem (on Windows at least).
Try:
npm i fsevents#latest -f --save-optional
That fixed the dependency issue for me.
I have the same issue with the GitHub Actions (is being used for style-checking and testing).
The error message appears while executing command npm ci:
fsevents not accessible from jest-haste-map
If I replace the npm ci by npm install, I receive the error about the lockfile version:
This version of npm is compatible with lockfileVersion#1, but package-lock.json was generated for lockfileVersion#2
Therefore, the reason of the issue is upgraded lockfile version to 2.
If you have the same issue, check the npm version (command) and package-lock.json (file). If the "lockfileVersion" is 2, npm must be at least 7.x.
To fix that in GitHub action I added npm-upgrading step. So, my steps looks like:
# ...
steps:
# ...
- name: Upgrade NPM
run: npm install -g npm
- name: Install dependencies
run: npm ci
- name: Build project
run: npm run build
Thus, if you have issue like "it works on my PC, but does not work in CI/CD runner", try to use described solution.
Try:
Deleting package-lock.json and node_modules
Running npm install locally, which should generate a new package-lock.json
Committing and pushing the new package-lock.json
I usually try this whenever I get strange npm errors like this relating to the dependencies.
I had this problem in bitbucket.org pipelines.
We was using Docker image with Node in version 14.17.0 (npm was included in version 6.14.13).
Updating only npm to version 8.1.3 did not help.
But updating Docker image of Node to new LTS version (16.13.0, with npm 8.1.0) fixed this problem and npm ci started working properly.
I saw this error this week. I changed package versions, then the error has gone. Here are my versions that seem related to this error. I'm not sure this is the correct way to fix it.
"#testing-library/jest-dom": "^5.14.1",
"#testing-library/react": "^11.2.7",
"#testing-library/user-event": "^13.1.9"
The same issue happen to me when build the package using ./github/worflows
Run npm ci
npm ERR! fsevents not accessible from jest-haste-map
1 - To resolve, I install in my local:
npm i fsevents#latest -f --save-optional
2 - Push the package.json into github again.
The workflows(view from github repository-> tab Actions) is triggered, the result shows the build is success.

Installation LoopBack-CLI error node-gyp rebuild

Hi Im installing the loopback-cli.
Running these commands:
npm install --global --production windows-build-tools
AND
npm install -g loopback-cli
The second command run rebuilding the ursa module into error. There is some link to C:\OpenSSL-Win64. What the ... is this? Some hardcoded library link?
Write me please some way how to install normally the loopback. This is from their installation site. Thanx.
Here the log:
C:\Users\Erik\AppData\Roaming\npm\node_modules\loopback-cli\node_modules\ursa>if not defined npm_config_node_gyp (node "C:\nodejs\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node "" rebuild )
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
ursaNative.cc
win_delay_load_hook.cc
..\src\ursaNative.cc(157): warning C4244: 'argument': conversion from 'ssize_t' to 'int', possible loss of data [C:\Use
rs\Erik\AppData\Roaming\npm\node_modules\loopback-cli\node_modules\ursa\build\ursaNative.vcxproj]
..\src\ursaNative.cc(172): warning C4244: 'argument': conversion from 'ssize_t' to 'int', possible loss of data [C:\Use
rs\Erik\AppData\Roaming\npm\node_modules\loopback-cli\node_modules\ursa\build\ursaNative.vcxproj]
LINK : fatal error LNK1181: cannot open input file 'C:\OpenSSL-Win64\lib\libeay32.lib' [C:\Users\Erik\AppData\Roaming\n
pm\node_modules\loopback-cli\node_modules\ursa\build\ursaNative.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (C:\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:258:23)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\nodejs\\node.exe" "C:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Users\Erik\AppData\Roaming\npm\node_modules\loopback-cli\node_modules\ursa
gyp ERR! node -v v8.9.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ursa#0.9.4 (node_modules\loopback-cli\node_modules\ursa):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ursa#0.9.4 install: `node-gyp rebuild`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
+ loopback-cli#4.0.0
added 3 packages and updated 1 package in 27.638s
Same issue here.
Setup before fixing:
lb -v 4.2.1 (generator-loopback#5.9.4 loopback-workspace#4.5.0)
node -v v10.13.0
OS: Windows 10 Home
I was able to fix the issue after taking the following steps:
Install node v8.12.0
Install OpenSSL 1.1 in C:\OpenSSL-Win64 (strong-ursa hard codes the location)
Create a symbolic link in C:\OpenSSL-Win64\lib named libeay64.lib which targets libcrypto.lib.
Run npm i -g windows-build-tools
Run npm i -g looback-cli again.
I'm not sure if rolling back the NodeJS version to 8.12 is necessary. There are a few widely, albeit not well documented pain points working with Loopback due to strong-ursa's use of native libraries. (Please note, this is unconfirmed information as I'm in a hurry to get back to developing the project at hand.) These steps allowed me to continue using Loopback CLI unhindered.
Useful links:
Download previous NodeJS releases: https://nodejs.org/en/download/releases/
Download OpenSSL: https://slproweb.com/products/Win32OpenSSL.html
windows-build-tools: https://github.com/felixrieseberg/windows-build-tools
https://github.com/curl/curl/issues/984
https://github.com/strongloop/loopback-cli/issues/36#issuecomment-434331508

Can't find phoenix 1.3 deps when deploying to heroku

I've run into this issue before, but can't recall how it was resolved. I'm trying to push an phx 1.3 app to heroku for the first time, but I get an error:
remote: npm ERR! addLocal Could not install /tmp/build_06158e99424e0327b7b56d1b5d95503a/deps/phoenix
remote: npm ERR! addLocal Could not install /tmp/build_06158e99424e0327b7b56d1b5d95503a/deps/phoenix_html
I seem to recall that in v1.3 the file structure was changed. My dependencies in package.json looks like:
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html"
},
elixir_buildpack.config:
always_rebuild=true
phoenix_static_buildpack.config:
assets_path=assets
phoenix_ex=phx
Am I missing anything else?

Now is not recognized as an internal or external command - when attempting to host a page with Zeit

"scripts": {
"start-js": "react-scripts start",
"start": "npm-run-all -p watch-css start-js",
"build": "npm run build-css && react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"build-css": "node-sass-chokidar src/ -o src/",
"watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --
watch --recursive",
"now-start": "node server/server.js",
"deploy": "now --public --dotenv=.env.prod -d"
},
"now": {
"alias": "lendahand"
}
}
Greetings. I'm trying to host a project with Zeit but I am getting an error I don't know how to fix. The error is saying that now is not an internal or external command, but it appears to be showing up in my package.json. I don't know how to remedy this situation. Do you have any suggestions?
The error is:
persona-project2-front#0.1.0 deploy C:\Users\Kim\DevMountain\LendAHandPP
> now --public --dotenv=.env.prod -d
'now' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! persona-project2-front#0.1.0 deploy: `now --public --
dotenv=.env.prod -d`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the persona-project2-front#0.1.0 deploy 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\Kim\AppData\Roaming\npm-cache\_logs\2017-11-
06T23_38_07_616Z-debug.log
Add the directory that now exists in to your PATH/path environmental variable, then you can use now. Make sure to close and re-open your terminal for the env. var. to take effect.
If that's not working, first make sure to install now like this:
npm install now -g to install it globally in your global npm/node_modules directory.
Then test it.
Thirdly, if that is not working, it could be a problem with the environmental variable not being set, so you may need to get root/administrator access and set that in the PATH env var for your system. As for the terminal, maybe try opening your terminal with admin access, or if on linux try something like sudo now.
Finally, after doing your npm install now -g it should display some messages like
'... -> C:\Users\\AppData\Roaming\npm\node_modules\now\download\dist\now ...'
Use that directory to work with now. This would open now process inside your terminal, your directory to now may be different, make sure to set this directory in your PATH if possible.

VS2015's npm support can't deal with #types?

I just found out that VS2015 has support for npm even in normal ASP.NET 4 projects - that's great.
The first thing I tried after jquery was to get types:
{
"version": "1.0.0",
"name": "aspnet",
"private": true,
"devDependencies": {
"jquery": "3.1.1",
"#types/jquery": "^2.0.34"
}
}
This says
npm ERR! 404 'types/jquery' is not in the npm registry.
I know it is, because executing
npm install
in the directory of the package.json file then installs it correctly.
That's a bug in VS2015's npm support, right? Is there a fix?

Resources