Can't install node-sass#6 for node v16 - node.js

This is my package.json after uninstalling sass node-sass and sass-loader because I changed my node version from 14 to 16,
{
"name": "our-awesome-project",
"version": "1.0.0",
"private": true,
"scripts": {
"dev": "nuxt",
"build": "nuxt build",
"start": "nuxt start",
"generate": "nuxt generate",
"static": "NUXTJS_DEPLOY_TARGET=static NUXTJS_SSR=true nuxt generate",
"build-and-start": "NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt build && NUXTJS_DEPLOY_TARGET=server NUXTJS_SSR=false nuxt start"
},
"husky": {
"hooks": {
"pre-commit": "cross-env PRE_COMMIT=true lint-staged -r"
}
},
"dependencies": {
"core-js": "^3.19.3",
"nuxt": "^2.15.8",
"nuxt-i18n": "^6.28.1",
"nuxt-purgecss": "^1.0.0",
"vue": "^2.6.14",
"vue-server-renderer": "^2.6.14",
"vue-template-compiler": "^2.6.14",
"webpack": "^4.46"
},
"devDependencies": {
"#nuxtjs/eslint-config": "^8.0.0",
"#nuxtjs/google-fonts": "^1.3.0",
"#nuxtjs/storybook": "^4.2.0",
"#nuxtjs/style-resources": "^1.2.1",
"#vue/cli-plugin-babel": "^4.5.15",
"babel-eslint": "^10.1.0",
"eslint": "^8.7.0",
"husky": "^7.0.4",
"nuxt-svg-loader": "^1.2.0",
"postcss": "^8.4.5"
}
}
According to this I should install node-sass version 6.0
But I'm trying:
npm install --save-dev sass#1.49.0 node-sass#6.0.1 sass-loader#10.2.1
Also, read here to add --unsafe-perm so I tried:
npm install --save-dev --unsafe-perm sass#1.49.0 node-sass#6.0.1 sass-loader#10.2.1
But it keeps failing, being the first error always this one:
npm ERR! code 1
npm ERR! path /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /Users/user/.nvm/versions/node/v16.13.1/bin/node /Users/toniweb/Proyectos/our-awesome-project/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
I tried removing node_modules package-lock.json and the same result
Of course, this is driving me nuts.. please tell me that anyone has an idea to try out

I think you are using ARM64 which is not supported by node-sass.
You should replace node-sass with sass(Dart Sass) as LibSass is deprecated
Just replace node-sass in your package.json file with sass. Both packages expose the same JavaScript API.
npm uninstall node-sass
npm install --save-dev sass

We have a Nuxt 2.15.8 app running on Node 16, in which a couple of months ago we switched from node-sass to sass, as the former is deprecated.
I recall at the time it took some figuring out, but in the end we just needed to install some postcss parsers to get the Nuxt app fully working with sass & sass-loader.
Taking as the baseline the package.json in your post, try:
npm install --save-dev \
sass#1.49.4 \
sass-loader#10.2.1 \
postcss-html#1.3.0 \
postcss-scss#4.0.3

The error message hints to node-gyp as the culprit. To work on a MacOS, node-gyp requires the XCode Command Line Tools to be installed (see here). So basically, in case you haven't done that yet, run
xcode-select --install
Or try any of the other methods described here. Then retry to install node-sass.

in fact , I think you have pasted the wrong error infomation.
there are two ways may help you
npm i --force this command will ignored the error in the package.json
use the pnpm , you can install it by
npm i -g pnpm
# then
pnpm i

Related

Fixing NPM vulnerabilities

I am following a TypeScript tutorial. Unfortunately, the packages are outdated and I got a warning about vulnerabilities.
I followed a bunch of suggestions from npm check and update package if needed, namely:
npm audit fix
npm audit fix --force
npm update
npm audit says there are still 24 vulnerabilities left. But none of the above commands will fix them.
npm outdated results in no output.
The vulnerable packages are:
ansi-regex
glob-parent
node-forge
nth-check
postcss
I don't actually know why they are part of my project, I don't have them in my package.json configuration.
What are the next steps of fixing these vulnerabilities?
I have tried:
How to fix npm vulnerabilities?
which has no answers.
updating the dependencies in package.json manually to newer versions and then running npm install. It didn't have an effect.
deleting package-lock.json according to a suggestion here and then run npm install again.
adding "ansi-regex": "^6.0.1", "glob-parent": "^6.0.2", "node-forge": "^1.3.0", "nth-check": "^2.0.1", "postcss": "^8.4.12" as as devDependencies and running npm install.
running npm i npm#latest as suggested in How to fix NPM vulnerabilities
How to fix npm vulnerabilities? I tried two methods, problems persist which didn't have any new suggestions
I have 5 moderate severity vulnerabilities when I checked the npm audit. How can I fix these errors given below? which also didn't suggest any new commands
running npm update glob-parent --depth 2 just to find out that --depth is deprecated and NPM always updates any depth [Github]
running npm prune
deleting the node_modules folder and running npm install again
You can reproduce my latest state with the following package.json in an empty directory and running npm install.
{
"name": "pacman",
"version": "0.0.1",
"description": "I just follow a tutorial. Nothing of interest.",
"keywords": ["game"],
"license": "MIT",
"author": "someone stupid",
"scripts": {
"build": "parcel build index.html",
"dev": "parcel index.html --open",
"start": "npm run build && npm run dev",
"test": "echo \"Error: no test specified\" && exit 1"
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^5.16.0",
"#typescript-eslint/parser": "^5.16.0",
"ansi-regex": "^6.0.1",
"eslint": "^8.12.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.0.0",
"glob-parent": "^6.0.2",
"node-forge": "^1.3.0",
"nth-check": "^2.0.1",
"parcel": "^2.4.0",
"parcel-bundler": "^1.12.5",
"postcss": "^8.4.12",
"prettier": "^2.6.1",
"typescript": "^4.6.3"
},
"dependencies": {
"npm": "^8.5.5"
}
}
This should give you 24 vulnerabilities, 18 moderate and 6 high (at the time of writing, running npm 8.5.5).
As per the comments, I have already tried all commands for the general case, in which case you need to start analyzing individual packages.
So, what did I do?
Update all dependencies to the latest version.
Next, perform a binary search by removing half of the dependencies and repeating the following steps
delete the node_modules folder
run npm install
run npm audit to check for the vulnerabilities
If there are no vulnerabilites, add the half of the remaining packages you want to install.
If there are vulnerabilities, remove the half of the packages you are currently installing.
In my case, this process boiled it down to the following two lines:
"parcel": "^2.4.0",
"parcel-bundler": "^1.12.5",
For parcel-bundler, NPM spit out a warning:
npm WARN deprecated parcel-bundler#1.12.5: Parcel v1 is no longer maintained.
Please migrate to v2, which is published under the 'parcel' package.
So I guess I don't need parcel-bundler at all, because it has been integrated into the parcel package, which I had already updated to version 2 in an earlier step.
Try to update all your npm with this command. It helped me
npm install -g npm#latest

npm install for angular 7 app errors with: Could not find module "#angular-devkit/build-ng-packagr" from .../.npm/_cacache/tmp

I'm no expert with JavaScript, node, npm, Angular, etc. I am a newbie with TypeScript. But I have inherited a application and I need to maintain it to fix a cross-site cookie problem.
So, I'm trying to get the development environment set up. I am stuck at npm install with a complaint of not finding a module #angular-devkit/build-ng-packagr. The same error happens when I try to explicitly install that module. Here is the log (with lots of similar lines omitted):
$ npm install #angular-devkit/build-ng-packagr
ngx-charts#0.0.0 prepack /home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2
npm run package
ngx-charts#0.0.0 package /home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2
npm run build:lib
ngx-charts#0.0.0 build:lib /home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2
ng build #swimlane/ngx-charts && npm run copy-files
Could not find module "#angular-devkit/build-ng-packagr" from "/home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2".
Error: Could not find module "#angular-devkit/build-ng-packagr" from "/home/kbuchs/.npm/_cacache/tmp/git-clone-a312e0b2".
at Object.resolve (/usr/lib/node_modules/#angular/cli/node_modules/#angular-devkit/core/node/resolve.js:141:11)
at Observable.rxjs_1.Observable [as _subscribe] (/usr/lib/node_modules/#angular/cli/node_modules/#angular-devkit/architect/src/architect.js:132:40)
at Observable._trySubscribe (/usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:44:25)
at Observable.subscribe (/usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:30:22)
at /usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:99:19
at new Promise (<anonymous>)
at Observable.toPromise (/usr/lib/node_modules/#angular/cli/node_modules/rxjs/internal/Observable.js:97:16)
at BuildCommand.initialize (/usr/lib/node_modules/#angular/cli/models/architect-command.js:88:94)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ngx-charts#0.0.0 build:lib: `ng build #swimlane/ngx-charts && npm run copy-files`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ngx-charts#0.0.0 build:lib script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kbuchs/.npm/_logs/2020-02-25T17_01_41_575Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ngx-charts#0.0.0 package: `npm run build:lib`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ngx-charts#0.0.0 package script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kbuchs/.npm/_logs/2020-02-25T17_01_41_608Z-debug.log
npm WARN tar ENOENT: no such file or directory, open '/home/kbuchs/git/host-analytics/node_modules/.staging/got-f7f3ba2c/package.json'
npm WARN tar ENOENT: no such file or directory, open '/home/kbuchs/git/host-analytics/node_modules/.staging/got-f7f3ba2c/index.js'
. . .
npm WARN #angular-devkit/build-ng-packagr#0.11.4 requires a peer of ng-packagr#^2.2.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm ERR! premature close
npm ERR! A complete log of this run can be found in:
npm ERR! /home/kbuchs/.npm/_logs/2020-02-25T15_51_50_301Z-debug.log
Somehow the build of ngx-charts is coming out of the package.json. Package.json has some scripts defined, but I don't know what would cause npm to want to start building when I just asked it to install.
Nothing ever gets installed in node_modules, by the way, for the above actions or any of what I describe below.
I'll insert my package.json at the bottom.
I have tried cleaning up to start from scratch. I removed the node_modules directory. Also removed ~/.npm/*. I tried all this using node version 13.
If I rename the package.json and package-lock.json files, I can install individual modules without a problem. With those files with their original names, I do note that trying to explicitly install a particular module, npm seems to run through building a full dependency tree for the contents of those files.
So, next, I tried to go back to the version of node that was current when the project was first created about 16 months ago, node 10.19.0. I installed the n module globally to do this (sudo npm install -g n). This changed the version of npm to 6.13.4. Still the same results were encountered.
I noticed the warning near the end about peer dependency of ng-packagr#^4.0.0 and tried to install that (npm install ng-packagr#^4.0.0). I got all the same errors but a different warning about a peer dependency on tsickle#>=0.34.0. Again,I tried npm install tsickle#>=0.34.0 and got all the same errors and more with a warning on a peer dependency on typescript#~3.7.2. So, I did sudo npm install -g typescript#~3.7.2 which worked fine with no errors or warnings. When I went back to try to install tsickle, again the errors came and the message about the peer dependency on typescript. It feels like I'm chasing my tail.
Can anyone suggest a way out?
My package.json:
{
"name": "analytics",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build.dev": "ng build -c dev",
"build.staging": "ng build -c staging",
"build.master": "ng build -c prod",
"deploy.dev": "cp app.dev.yaml dist/app.yaml && gcloud app deploy dist/app.yaml",
"deploy.staging": "cp app.staging.yaml dist/app.yaml && gcloud beta app deploy dist/app.yaml",
"deploy.master": "cp app.prod.yaml dist/app.yaml && gcloud beta app deploy dist/app.yaml",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular-devkit/build-ng-packagr": "~0.11.1",
"#angular/animations": "~7.1.0",
"#angular/common": "~7.1.0",
"#angular/compiler": "~7.1.0",
"#angular/core": "~7.1.0",
"#angular/forms": "~7.1.0",
"#angular/platform-browser": "~7.1.0",
"#angular/platform-browser-dynamic": "~7.1.0",
"#angular/router": "~7.1.0",
"#ng-bootstrap/ng-bootstrap": "^4.0.0",
"#priotas/angular-bootstrap-slider": "^1.1.26",
"#swimlane/ngx-charts": "github:swimlane/ngx-charts#master",
"#types/date-fns": "^2.6.0",
"auth0-js": "^9.8.2",
"bootstrap": "^4.0.0-beta.3",
"bootstrap-slider": "^10.3.4",
"compact-timezone-list": "^1.0.6",
"core-js": "^2.5.4",
"d3": "^5.7.0",
"date-fns": "^1.30.1",
"font-awesome": "^4.7.0",
"html2canvas": "^1.0.0-alpha.12",
"html2pdf": "0.0.11",
"jspdf": "^1.5.3",
"lodash": "^4.17.11",
"moment": "^2.22.2",
"moment-timezone": "^0.5.23",
"ng-multiselect-dropdown": "^0.2.3",
"ng2-timezone-selector": "^0.2.4",
"ngx-webstorage-service": "^3.1.1",
"print-js": "^1.0.54",
"rxjs": "~6.3.3",
"tslib": "^1.9.0",
"zone.js": "~0.8.26"
},
"devDependencies": {
"#angular-devkit/build-angular": "~0.11.0",
"#angular/cli": "~7.1.1",
"#angular/compiler-cli": "~7.1.0",
"#angular/language-service": "~7.1.0",
"#types/jasmine": "~2.8.8",
"#types/jasminewd2": "~2.0.3",
"#types/lodash": "^4.14.120",
"#types/node": "^8.10.45",
"codelyzer": "~4.5.0",
"jasmine-core": "~2.99.1",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~3.1.1",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2",
"ncp": "^2.0.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tslint": "~5.11.0",
"typescript": "~3.1.6"
}
}
Since this is an Angular 7 app, that points to it being older code, which makes me suspect that this is probably not a valid dependency:
"#swimlane/ngx-charts": "github:swimlane/ngx-charts#master",
since that's going to pull the current version of ngx-charts from github. Looking at releases, Angular 7.1.0 was released in Nov. 2018 (ref: https://github.com/angular/angular-cli/releases/tag/v.7.1.0); so I'd try using a version of ngx-charts that was contemporary to that (it looks like 10.0.0 or 10.1.0 would be good bets, per https://github.com/swimlane/ngx-charts/releases).
So ... to be safe:
rm -r package-lock.json node_modules
npm i --save #swimlane/ngx-charts#10.1.0
npm install
...see if that does the trick.

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.

Running Existing Angular Project locally

I am very new to Angular, I am trying to run an existing project of Angular on my machine. I have done a lot of tests and followed a lot of articles. But cannot run my project.
I have the project files like this:
I installed the nodejs on my system.
And followed the following instructions as per an article:
change directory to our repo
cd myproject
installing Cli according to project readme file.
npm install -g #angular/cli#1.3.2
install the repo with npm
npm install
install TypeScript typings
npm run typings-install
-- Gives error: npm ERR! missing script: typings-install
Then I try the following:
npm install --global
For following:
webpack (npm install --global webpack)
webpack-dev-server (npm install --global webpack-dev-server)
karma (npm install --global karma-cli)
protractor (npm install --global protractor)
typings (npm install --global typings)
typescript (npm install --global typescript)
start the server
npm start
-- Gives multiple error messages:
Such as:
npm ERR! code ELIFECYCLE
-- For this I tried "npm cache clean" and then deleted "node_modules" and then installed packages again using: "npm install --save"
Then tried again: npm start it gave me same error "npm ERR! code ELIFECYCLE"
Also, this error message:
Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
For this, I tried "npm uninstall -g webpack"
and then: npm install --save-dev webpack webpack-cli html-webpack-plugin webpack-dev-server webpack-dev-middleware from this: Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Tried running it again:
this time it gave me following error:
ERROR in ./node_modules/raw-loader!./node_modules/#angular/cli/node_modules/post
css-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--8-3!./sr
c/styles.scss
Module build failed: Error: Cannot find module 'node-sass'
For this "Cannot find module 'node-sass'" I did the search again:
and found this command: npm install node-sass
i tried it and then tried starting again
Now I received ERROR in No NgModule metadata found for 'AppModule'.
And for this I tried the following from git cli issues 8798
remove the node_modules folder
rm -rf node_modules
remove the webpack
npm remove webpack
clean npm cahe
npm cache clean --force
install the latest version of angular cli
npm install --save-dev #angular/cli#latest
install the dependencies
npm install
now it's just testing
npm start our ng serve
Now it start giving me: Local workspace file ('angular.json') could not be found and wont work at all.
To resolve this: I did: ng update #angular/cli --migrate-only --from=1.7.4
Which remove the error: "Local workspace file ('angular.json') could not be found" but now it gives me error
ERROR in src/app/web-player/albums/album-context-menu/album-context-menu.compon
nt.ts(13,14): error TS2515: Non-abstract class 'AlbumContextMenuComponent' does
not implement inherited abstract member 'getAllTracks' from class 'ContextMenuC
mponent<Album>'.
src/app/web-player/artists/artist-context-menu/artist-context-menu.component.ts
13,14): error TS2515: Non-abstract class 'ArtistContextMenuComponent' does not
mplement inherited abstract member 'getAllTracks' from class 'ContextMenuCompon
nt<Artist>'.
src/app/web-player/context-menu/context-menu.component.ts(58,34): error TS2304:
Cannot find name 'TrackList'.
src/app/web-player/playlists/playlist-context-menu/playlist-context-menu.compon
nt.ts(15,14): error TS2515: Non-abstract class 'PlaylistContextMenuComponent' d
es not implement inherited abstract member 'getAllTracks' from class 'ContextMe
uComponent<Playlist>'.
What am i missing here? I tried a lot of articles from 3 days but cannot run it.
Also, I see different types of Warning and messages.
Read Me file in project:
# Client
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.3.2.
## Development server
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
## Code scaffolding
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
## Build
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `-prod` flag for a production build.
## Running unit tests
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Running end-to-end tests
Run `ng e2e` to execute the end-to-end tests via [Protractor](http://www.protractortest.org/).
Before running the tests make sure you are serving the app via `ng serve`.
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).
Package.json file:
{
"name": "client",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json --host 0.0.0.0",
"build": "ng build --prod --sourcemaps --build-optimizer",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"#angular/animations": "^5.1.2",
"#angular/common": "^5.1.2",
"#angular/compiler": "^5.1.2",
"#angular/core": "^5.1.2",
"#angular/forms": "^5.1.2",
"#angular/http": "^5.1.2",
"#angular/platform-browser": "^5.1.2",
"#angular/platform-browser-dynamic": "^5.1.2",
"#angular/router": "^5.1.2",
"bootstrap": "^4.0.0-beta",
"chart.js": "^2.7.0",
"copy-to-clipboard": "^3.0.8",
"core-js": "^2.5.1",
"hammerjs": "^2.0.8",
"moment": "^2.18.1",
"ng-lazyload-image": "^3.3.3",
"ngx-color-picker": "^4.3.4",
"normalize.css": "^7.0.0",
"perfect-scrollbar": "^0.8.1",
"popper.js": "^1.12.5",
"raven-js": "^3.18.1",
"rxjs": "^5.4.2",
"svg4everybody": "^2.1.4",
"tooltip.js": "^1.1.5",
"zone.js": "^0.8.18"
},
"devDependencies": {
"#angular/cli": "^1.6.2",
"#angular/compiler-cli": "^5.1.2",
"#angular/language-service": "^5.1.2",
"#types/hammerjs": "^2.0.35",
"#types/jasmine": "~2.5.53",
"#types/jasminewd2": "^2.0.3",
"#types/node": "~6.0.60",
"#types/popper.js": "^1.10.1",
"#types/youtube": "0.0.31",
"#types/clipboard": "^1.5.35",
"cheerio": "^1.0.0-rc.2",
"codelyzer": "~3.1.1",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"gulp-filter": "^5.0.0",
"gulp-rename": "^1.2.2",
"gulp-svgmin": "^1.2.3",
"gulp-svgstore": "^6.1.0",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"karma": "^1.7.1",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"material-design-icons": "^3.0.1",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2",
"webpack-bundle-analyzer": "^2.9.0"
}
}
Run the following commands
npm uninstall -g #angular/cli
npm cache verify
npm install -g #angular/cli#next
npm update
Then
ng serve
I hope it works now. Comment if u face any error while.
That should be much easier...
Take your project files as is
Run npm install
Since you have the package.json file, it will read all dependencies and install them.
Then run npm audit fix if needed (the terminal will tell you that).
try ng serve --open
it will compile your project and directly open in browser
rename the file .angular-cli.json to angular.json and re run the ng serve --open command.
Change the path of the directory in your local
cd my-repo
npm install
ng serve or ng serve --open
You will find the Localhost then.
To clean the cache:
npm cache clean
I also had need to setup existing angular project.
*cli version as per your package.json file
npm install -g #angular/cli#1.3.2
Then
npm install
Then
ng serve
I have tested, it is working here.

Node/React app won't deploy to Heroku

My app has a React frontend and a Node backend; the BE serves the FE data through an API. It won't deploy to Heroku—stack trace is below.
Things I've tried:
This question. I've tried modelling my package.json files after a model repo mentioned in the answer, but no luck.
Deploying the model repo mentioned above—it worked fine.
Deploying the model repo to my own failing heroku app—it worked fine, so Heroku isn't the issue.
This question (I've checked react-scripts is listed as a dependency and not a dev-dependency).
I will probably end up taking the model repo as a starting point and gradually copying my project over, but would appreciate any info on what might be going wrong.
Stack Trace:
> fsevents#1.0.17 install /tmp/build_f03b382a2b768aeb89ff9c197145d0a5/client/node_modules/fsevents
> node-pre-gyp install --fallback-to-build
node-pre-gyp ERR! Tried to download(404): https://fsevents-binaries.s3-us-west-2.amazonaws.com/v1.0.17/fse-v1.0.17-node-v48-linux-x64.tar.gz
node-pre-gyp ERR! Pre-built binaries not found for fsevents#1.0.17 and node#6.10.3 (node-v48 ABI) (falling back to source compile with node-gyp)
make: Entering directory '/tmp/build_f03b382a2b768aeb89ff9c197145d0a5/client/node_modules/fsevents/build'
SOLINK_MODULE(target) Release/obj.target/.node
COPY Release/.node
make: Leaving directory '/tmp/build_f03b382a2b768aeb89ff9c197145d0a5/client/node_modules/fsevents/build'
> fibers#1.0.15 install /tmp/build_f03b382a2b768aeb89ff9c197145d0a5/client/node_modules/fibers
> node build.js || nodejs build.js
`linux-x64-48` exists; testing
Binary is fine; exiting
added 1242 packages in 52.433s
removed 1242 packages in 25.561s
> react-ui#0.1.0 build /tmp/build_f03b382a2b768aeb89ff9c197145d0a5/client
> react-scripts build
sh: 1: react-scripts: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! react-ui#0.1.0 build: `react-scripts build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the react-ui#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My server package.json:
{
"name": "in-search-of-happiness",
"engines": {
"node": "6.10.x"
},
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www",
"heroku-postbuild": "cd client/ && npm install --only=dev && npm install && npm run build"
},
"cacheDirectories": [
"node_modules",
"client/node_modules"
],
"dependencies": {
"body-parser": "^1.17.2",
"cookie-parser": "^1.4.3",
"debug": "~2.6.3",
"express": "~4.15.2",
"jade": "^1.11.0",
"mongoose": "^4.10.8",
"morgan": "^1.8.2",
"serve-favicon": "^2.4.3",
"zombie": "^5.0.5"
}
}
My React package.json:
{
"name": "react-ui",
"version": "0.1.0",
"private": true,
"dependencies": {
"bootstrap": "^3.3.7",
"fetch": "^1.1.0",
"node-fetch": "^1.7.1",
"process-nextick-args": "^1.0.7",
"react": "^15.6.1",
"react-bootstrap": "^0.31.0",
"react-dom": "^15.6.1",
"react-scripts": "1.0.7",
"util-deprecate": "^1.0.2"
},
"devDependencies": {
"chai": "^4.0.2",
"eslint": "^4.0.0",
"sinon": "^2.3.5",
"wdio-mocha-framework": "^0.5.10",
"webdriverio": "^4.8.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"proxy": "http://localhost:3001"
}
Hello your post build script needs some modification, kindly follow this convention
Replace reactFolderName to your folder name that contains the react frontend
Add This below snippet to your package.json under the scripts
scripts{
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix reactFolderName && npm run build --prefix reactFolderName"
}
And add this snippet to your index.js file
app = express()
app.use(express.static('reactFolderName/build'));
app.get('*', (req, res) => res.sendFile(path.resolve(__dirname, 'reactFolderName', 'build', 'index.html')));

Resources