how to run test inside a nextjs project - jestjs

I need to use react-testing-library for unit test cases in nextjs application. In react applications which was created using create react app, I used to just call npm run test and the test scripts run.
But in nexJs while trying to calling npm run test if gives errors.
The nextjs application was created using create-next-app.
I installed react-testing-library manually into nextjs application.
I installed:
#testing-library/react
#testing-library/jest-dom
#testing-library/user-event
jest
babel-jest
And in package.js added the test script:
"test": "jest"
package.json:
{
"name": "thestobook",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "jest"
},
"dependencies": {
"#emotion/react": "^11.7.1",
"#emotion/styled": "^11.6.0",
"#material-ui/core": "^4.12.3",
"#material-ui/icons": "^4.11.2",
"#mui/icons-material": "^5.3.1",
"#mui/material": "^5.4.0",
"#testing-library/jest-dom": "^5.16.4",
"#testing-library/react": "^13.2.0",
"#testing-library/user-event": "^14.2.0",
"#types/axios": "^0.14.0",
"axios": "^0.25.0",
"babel-jest": "^28.1.0",
"bcryptjs": "^2.4.3",
"formik": "^2.2.9",
"jest": "^28.1.0",
"js-cookie": "^3.0.1",
"jsonwebtoken": "^8.5.1",
"mongoose": "^6.2.0",
"next": "12.0.10",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-outside-click-handler": "^1.3.0",
"react-slugify": "^2.1.0",
"react-test-renderer": "^18.1.0",
"react-toastify": "^8.2.0",
"recoil": "^0.6.1",
"sass": "^1.49.4",
"slugify": "^1.6.5",
"use-image-color": "0.0.9",
"yup": "^0.32.11"
},
"devDependencies": {
"#types/node": "17.0.14",
"#types/react": "17.0.38",
"eslint": "8.8.0",
"eslint-config-next": "12.0.10",
"typescript": "4.5.5"
}
}
After installation, Created jest.config.js:
module.exports = {
setupFilesAfterEnv: ["./jest.setup.js"],
};
also created jest.setup.js:
import "#testing-library/jest-dom";
test file created in __ test __ folder --> ComponentName.test.js
import { render, screen } from "#testing-library/react";
import Profile from "../Profile";
it("should be same as the text passed", () => {
render(<Profile />);
const textElement = screen.getByText(/explore/i);
expect(textElement).toBeInTheDocument();
});
While npm run test, It runs the test but after that gives error.
Error in terminal:
Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.343 s
Ran all test suites.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! thestobook# test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the thestobook# test 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! /Users/saikrishnadas/.npm/_logs/2022-05-25T09_49_40_372Z-debug.log
Complete Error Log:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'test' ]
2 info using npm#6.14.13
3 info using node#v14.17.1
4 verbose run-script [ 'pretest', 'test', 'posttest' ]
5 info lifecycle thestobook#~pretest: thestobook#
6 info lifecycle thestobook#~test: thestobook#
7 verbose lifecycle thestobook#~test: unsafe-perm in lifecycle true
8 verbose lifecycle thestobook#~test: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/saikrishnadas/thestobook/thestobook/node_modules/.bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/homebrew/bin:/opt/homebrew/sbin
9 verbose lifecycle thestobook#~test: CWD: /Users/saikrishnadas/sai-learn/thestobook/thestobook
10 silly lifecycle thestobook#~test: Args: [ '-c', 'jest' ]
11 silly lifecycle thestobook#~test: Returned: code: 1 signal: null
12 info lifecycle thestobook#~test: Failed to exec test script
13 verbose stack Error: thestobook# test: `jest`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:375:28)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:375:28)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid thestobook#
15 verbose cwd /Users/saikrishnadas/thestobook/thestobook
16 verbose Darwin 21.1.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test"
18 verbose node v14.17.1
19 verbose npm v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error thestobook# test: `jest`
22 error Exit status 1
23 error Failed at the thestobook# test script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Related

What are the ways to resolve npm run dev error?

I deployed my Laravel version 7 project on Hostinger. I managed to set up my project and installed node using nvm but when I run npm run dev, it just won't execute.
I tried to execute:
npm cache clean --force
rm -rf node_modules package-lock.json
npm install
and npm rebuild
but nothing changes and the error is still there.
Here is my error log:
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli '/home/u618667693/.nvm/versions/node/v14.17.0/bin/node',
1 verbose cli '/home/u618667693/.nvm/versions/node/v14.17.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'prod'
1 verbose cli ]
2 info using npm#6.14.13
3 info using node#v14.17.0
4 verbose run-script [ 'preprod', 'prod', 'postprod' ]
5 info lifecycle #~preprod: #
6 info lifecycle #~prod: #
7 verbose lifecycle #~prod: unsafe-perm in lifecycle true
8 verbose lifecycle #~prod: PATH: /home/u618667693/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/u618667693/domains/expensetracker.site/expense-tracker/node_modules/.bin:/home/u618667693/.nvm/versions/node/v14.17.0/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
9 verbose lifecycle #~prod: CWD: /home/u618667693/domains/expensetracker.site/expense-tracker
10 silly lifecycle #~prod: Args: [ '-c', 'npm run production' ]
11 silly lifecycle #~prod: Returned: code: 1 signal: null
12 info lifecycle #~prod: Failed to exec prod script
13 verbose stack Error: # prod: `npm run production`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/u618667693/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:376:20)
13 verbose stack at ChildProcess.<anonymous> (/home/u618667693/.nvm/versions/node/v14.17.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:376:20)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid #
15 verbose cwd /home/u618667693/domains/expensetracker.site/expense-tracker
16 verbose Linux 4.18.0-147.8.1.el7h.lve.1.x86_64
17 verbose argv "/home/u618667693/.nvm/versions/node/v14.17.0/bin/node" "/home/u618667693/.nvm/versions/node/v14.17.0/bin/npm" "run" "prod"
18 verbose node v14.17.0
19 verbose npm v6.14.13
20 error code ELIFECYCLE
21 error errno 1
22 error # prod: `npm run production`
22 error Exit status 1
23 error Failed at the # prod script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
This is my package.json file:
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "npm run development -- --watch",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --disable-host-check --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "npm run production",
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.0.0",
"cross-env": "^7.0.3",
"deepmerge": "^4.2.2",
"jquery": "^3.2",
"laravel-mix": "^5.0.1",
"lodash": "^4.17.19",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.32.13",
"sass-loader": "^8.0.2",
"vue": "^2.5.17",
"vue-template-compiler": "^2.6.10"
},
"dependencies": {
"#mdi/font": "^5.9.55",
"chart.js": "^2.9.4",
"chartjs-plugin-datalabels": "^1.0.0",
"moment": "^2.29.1",
"numeral": "^2.0.6",
"pdfmake": "^0.1.71",
"randomcolor": "^0.6.2",
"vue-chartjs": "^3.5.1",
"vue-router": "^3.5.1",
"vuetify": "^2.5.0",
"vuetify-confirm": "^2.0.6",
"vuetify-dialog": "^2.0.14",
"vuex": "^3.6.2",
"vuex-persistedstate": "^4.0.0-beta.3"
}
}
Thank you in advance.

npm run build Reactjs errno1

Problem description
I have a react project, the project runs well with the command 'npm start'. But in executing the command 'npm run build', I get this error:
verbose node v12.16.3
verbose npm v6.14.4
error code ELIFECYCLE
error errno 1
error demo1#6.1.5 build: `react-scripts build`
error Exit status 1
error Failed at the demo1#6.1.5 build script.
error This is probably not a problem with npm. There is likely additional logging output above.
This is my Package.json :
{
"name": "demo1",
"version": "6.1.5",
"private": true,
"homepage": ".",
"scripts": {
"serve": "cp-cli build _site/metronic/preview/react && serve",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"lint": "eslint src",
"format": "prettier --write \"src/**/*.{js,css,scss,html}\"",
"rtl": "webpack"
},
"eslintConfig": {
"extends": "react-app"
}
},
"dependencies": {
"#date-io/date-fns": "^1.3.11",
"#formatjs/intl-pluralrules": "^1.3.5",
"#material-ui/core": "^4.9.9",
"#material-ui/lab": "^4.0.0-alpha.33",
"#material-ui/styles": "^4.6.0",
"#tanem/svg-injector": "^8.0.35",
"array-unique": "^0.3.2",
"bootstrap": "^4.4.1",
"cp-cli": "^2.0.0",
"dentist": "^1.0.3",
"fg-loadcss": "^2.1.0",
"formik": "^2.0.6",
"jss-rtl": "^0.3.0",
"lodash": "^4.17.15",
"object-path": "^0.11.4",
"prop-types": "^15.7.2",
"react": "^16.12.0",
"react-bootstrap": "1.0.0-beta.16",
"react-dom": "^16.12.0",
"redux": "^4.0.4",
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3"
.
.
}
}
"devDependencies": {
"#ionic/cli-plugin-proxy": "1.5.8",
"copyfiles": "^2.1.1",
"node-sass": "^4.13.0",
"prettier": "^1.19.1",
"serve": "^11.2.0",
"webpack-cli": "^3.3.10",
"webpack-messages": "^2.0.4",
"webpack-rtl-plugin": "^2.0.0"
}
Additional info
I have tried solutions like: clean and delete node_modules and then install npm.But I'm still wrong.
Full error description in log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\..\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.3
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle demo1#6.1.5~prebuild: demo1#6.1.5
6 info lifecycle demo1#6.1.5~build: demo1#6.1.5
7 verbose lifecycle demo1#6.1.5~build: unsafe-perm in lifecycle true
8 verbose lifecycle demo1#6.1.5~build: PATH: C:\..\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;G:\EAMS\EAMS _FINAL\EAMS.Web.Portal\ClientApp\node_modules\.bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\130\Tools\Binn\;C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\Microsoft SQL Server\130\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\150\DTS\Binn\;C:\Program Files\dotnet\;C:\Program Files\Git\cmd;C:\Program Files (x86)\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\Tools\Binn\;C:\Program Files\Microsoft SQL Server\140\DTS\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn\;C:\Program Files (x86)\dotnet\;C:\Program Files\nodejs\;C:\..\AppData\Local\Microsoft\WindowsApps;;C:\Users\960145\AppData\Local\Programs\Microsoft VS Code\bin;C:\..\.dotnet\tools;C:\..\AppData\Roaming\npm
9 verbose lifecycle demo1#6.1.5~build: CWD: G:\EAMS\EAMS _FINAL\EAMS.Web.Portal\ClientApp
10 silly lifecycle demo1#6.1.5~build: Args: [ '/d /s /c', 'react-scripts build' ]
11 silly lifecycle demo1#6.1.5~build: Returned: code: 1 signal: null
12 info lifecycle demo1#6.1.5~build: Failed to exec build script
13 verbose stack Error: demo1#6.1.5 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Users\960145\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:310:20)
13 verbose stack at ChildProcess.<anonymous> (C:\..\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:310:20)
13 verbose stack at maybeClose (internal/child_process.js:1021:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid demo1#6.1.5
15 verbose cwd G:\..\ClientApp
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\..\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "build"
18 verbose node v12.16.3
19 verbose npm v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error demo1#6.1.5 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the demo1#6.1.5 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Try this:
npm cache clean --force
delete node_modules (manually)
npm install
npm run rtl
npm start

Updated Create-React-App no longer builds

Something interesting happened. I added some libraries (material ui) which forced me to update my 16.3 version of react to hooks (16.8) but unfortunately due a package not supporting react-scripts 2.x I had to stick with react-scripts: 1.1.0 and everything was still running fine with npm run start but now when I try to build with npm run build I get a UglifyJS error: maxium call stack size exceeded.
I tried removing/reinstalling node_modules and it didn't help.
I searched all the other topics and unfortunately none of them seemed to match my situation as I have not touched Babel, webpack, or ejected.
Note: I have NOT ejected the Create-React-App.
TERMINAL ERROR MESSAGE:
Creating an optimized production build...
Failed to compile.
Failed to minify the bundle. Error: static/js/main.5a18352c.js from UglifyJs
RangeError: Maximum call stack size exceeded
at compiler.run (/Users/mike/Documents/Websites/mySite/viewer/node_modules/react-scripts/scripts/build.js:128:23)
at emitRecords.err (/Users/mike/Documents/Websites/mySite/viewer/node_modules/webpack/lib/Compiler.js:269:13)
at Compiler.emitRecords (/Users/mike/Documents/Websites/mySite/viewer/node_modules/webpack/lib/Compiler.js:375:38)
at emitAssets.err (/Users/mike/Documents/Websites/mySite/viewer/node_modules/webpack/lib/Compiler.js:262:10)
at applyPluginsAsyncSeries1.err (/Users/mike/Documents/Websites/mySite/viewer/node_modules/webpack/lib/Compiler.js:368:12)
at next (/Users/mike/Documents/Websites/mySite/viewer/node_modules/tapable/lib/Tapable.js:218:11)
at Compiler.compiler.plugin (/Users/mike/Documents/Websites/mySite/viewer/node_modules/webpack/lib/performance/SizeLimitsPlugin.js:99:4)
at next (/Users/mike/Documents/Websites/mySite/viewer/node_modules/tapable/lib/Tapable.js:220:14)
at /Users/mike/Documents/Websites/mySite/viewer/node_modules/sw-precache-webpack-plugin/lib/index.js:98:18
Here is error log from the npm run build (I changed some sensitive info)
debug.log (npm run build):
0 info it worked if it ends with ok
1 verbose cli [ '/Users/mike/.nvm/versions/node/v10.18.0/bin/node',
1 verbose cli '/Users/mike/.nvm/versions/node/v10.18.0/bin/npm',
1 verbose cli 'run',
1 verbose cli 'build' ]
2 info using npm#6.13.4
3 info using node#v10.18.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle mySite-Web-Application#1.2.10-w~prebuild: mySite-Web-Application#1.2.10-w
6 info lifecycle mySite-Web-Application#1.2.10-w~build: mySite-Web-Application#1.2.10-w
7 verbose lifecycle mySite-Web-Application#1.2.10-w~build: unsafe-perm in lifecycle true
8 verbose lifecycle mySite-Web-Application#1.2.10-w~build: PATH: /Users/mike/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/mike/Documents/Websites/mySite/viewer/node_modules/.bin:/Users/mike/.nvm/versions/node/v10.18.0/bin:/Users/mike/google-cloud-sdk/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/mike/.nvm/versions/node/v10.18.0/bin:/Users/mike/google-cloud-sdk/bin
9 verbose lifecycle mySite-Web-Application#1.2.10-w~build: CWD: /Users/mike/Documents/Websites/mySite/viewer
10 silly lifecycle mySite-Web-Application#1.2.10-w~build: Args: [ '-c', 'react-scripts build && rm build/static/js/*.map' ]
11 silly lifecycle mySite-Web-Application#1.2.10-w~build: Returned: code: 1 signal: null
12 info lifecycle mySite-Web-Application#1.2.10-w~build: Failed to exec build script
13 verbose stack Error: mySite-Web-Application#1.2.10-w build: `react-scripts build && rm build/static/js/*.map`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/Users/mike/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/Users/mike/.nvm/versions/node/v10.18.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid mySite-Web-Application#1.2.10-w
15 verbose cwd /Users/mike/Documents/Websites/mySite/viewer
16 verbose Darwin 18.2.0
17 verbose argv "/Users/mike/.nvm/versions/node/v10.18.0/bin/node" "/Users/mike/.nvm/versions/node/v10.18.0/bin/npm" "run" "build"
18 verbose node v10.18.0
19 verbose npm v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error mySite-Web-Application#1.2.10-w build: `react-scripts build && rm build/static/js/*.map`
22 error Exit status 1
23 error Failed at the mySite-Web-Application#1.2.10-w build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
Package.json:
{
"name": "Mysite-Web-Application",
"version": "1.2.10w",
"private": true,
"homepage": "http://www.mysite.ca/app/",
"dependencies": {
"#material-ui/core": "^4.5.1",
"#material-ui/icons": "^4.5.1",
"#sentry/browser": "^5.7.1",
"bootstrap": "^4.3.1",
"date-fns": "^1.30.1",
"default-passive-events": "^1.0.10",
"dompurify": "^1.0.11",
"exif-js": "^2.3.0",
"firebase": "^7.2.2",
"firebase-auto-ids": "^1.1.0",
"hammer-touchemulator": "0.0.2",
"hammerjs": "^2.0.8",
"install": "^0.11.2",
"konva": "^4.0.16",
"lodash": "^4.17.15",
"moment": "^2.24.0",
"moment-timezone": "^0.5.27",
"normalize.css": "^8.0.1",
"npm": "^6.12.0",
"pdfjs-dist": "^2.2.228",
"prop-types": "^15.7.2",
"react": "^16.8.0",
"react-app-polyfill": "^1.0.4",
"react-beautiful-dnd": "^9.0.2",
"react-collapse": "^5.0.0",
"react-datepicker": "^2.9.6",
"react-dom": "^16.8.0",
"react-image-gallery": "^0.8.18",
"react-konva": "^16.10.1-0",
"react-pdf": "^2.5.3",
"react-responsive-modal": "^3.6.0",
"react-router-dom": "^4.3.1",
"react-router-hash-link": "^1.2.2",
"react-scripts": "1.1.0",
"tesseract.js": "^1.0.19"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build && rm build/static/js/*.map",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
},
"browserslist": {
"production": [
">0.2%",
"not op_mini all"
],
"development": [
"last 2 chrome version",
"last 2 firefox version",
"last 2 safari version"
]
},
"devDependencies": {
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint-plugin-react-hooks": "^2.2.0"
}
}
Try to run rm -rf node_modules in the root folder and npm install after
I had the same problem, and was a icon i had added in a component, with #material-ui/icons. When i removed it, i could build again, but i don't found the solution too.
I had some issues with my build as well. Whist checking around in the community for solutions, I came across this repository:
A Frontend build config generator
TLTR; Basically its a boilerplate that can get up and going quickly!
SO% to the developer being the c - https://github.com/jakoblind.

Conflict of Node versions

I have on local Windows node v8.12.0 and npm v6.4.1. On the server I have node v11.10.0 and npm v6.7.0.
I replaced project in server with backup on local machine, but when I type npm start I have this error.
sh: 1: react-app-rewired: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! manager-polling-app-client#0.1.0 start: `react-app-rewired start`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the manager-polling-app-client#0.1.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! /root/.npm/_logs/2020-01-14T05_41_00_295Z-debug.log
Is it possible that project does not start on server due to conflict of node version? If yes, should I upgrade node on local or downgrade node on server?
P.S. I think chmod -R 777 will NOT solve problem, because other files on server has the same rights and they start with no problem.
P.P.S. there is my package.json file if it`s needed
{
"name": "manager-polling-app-client",
"version": "0.1.0",
"private": true,
"dependencies": {
"#material-ui/core": "^3.9.3",
"ajv": "^6.9.1",
"ajv-keywords": "^3.4.1",
"antd": "^3.20.0",
"arui-feather": "^12.12.0",
"b64-to-blob": "^1.2.19",
"moment": "^2.22.2",
"pdfmake": "^0.1.53",
"prop-types": "^15.7.2",
"react": "^16.2.0",
"react-awesome-modal": "^2.0.5",
"react-data-export": "^0.5.0",
"react-dom": "^16.2.0",
"react-export-excel": "^0.5.3",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.1",
"react-select": "^2.4.2",
"xlsx": "^0.14.4"
},
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test --env=jsdom",
"eject": "react-scripts eject"
},
"devDependencies": {
"babel-plugin-import": "^1.11.0",
"react-app-rewire-less": "^2.1.3",
"react-app-rewired": "^1.6.2"
}
}
P.P.P.S. Log file
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm#6.7.0
3 info using node#v11.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle manager-polling-app-client#0.1.0~prestart: manager-polling-app- client#0.1.0
6 info lifecycle manager-polling-app-client#0.1.0~start: manager-polling-app-cli ent#0.1.0
7 verbose lifecycle manager-polling-app-client#0.1.0~start: unsafe-perm in lifec ycle true
8 verbose lifecycle manager-polling-app-client#0.1.0~start: PATH: /usr/local/lib /node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/root/mybpm/manager-po lling-app-client/node_modules/.bin:/usr/lib/jvm/java-8-openjdk-amd64/bin:/usr/lo cal/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game s:/snap/bin
9 verbose lifecycle manager-polling-app-client#0.1.0~start: CWD: /root/mybpm/man ager-polling-app-client
10 silly lifecycle manager-polling-app-client#0.1.0~start: Args: [ '-c', 'react- app-rewired start' ]
11 silly lifecycle manager-polling-app-client#0.1.0~start: Returned: code: 126 signal: null
12 info lifecycle manager-polling-app-client#0.1.0~start: Failed to exec start s cript
13 verbose stack Error: manager-polling-app-client#0.1.0 start: `react-app-rewir ed start`
13 verbose stack Exit status 126
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/np m/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:197:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/np m/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:197:13)
13 verbose stack at maybeClose (internal/child_process.js:984:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_proc ess.js:265:5)
14 verbose pkgid manager-polling-app-client#0.1.0
15 verbose cwd /root/mybpm/manager-polling-app-client
16 verbose Linux 4.4.0-135-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v11.10.0
19 verbose npm v6.7.0
20 error code ELIFECYCLE
21 error errno 126
22 error manager-polling-app-client#0.1.0 start: `react-app-rewired start`
22 error Exit status 126
23 error Failed at the manager-polling-app-client#0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional log

Error on "npm install"

I received a node.js project and I can't execute npm install, when I try to do it, it gives me this error:
0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'start' ]
2 info using npm#5.6.0
3 info using node#v8.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle park-administrative-interface#0.1.1~prestart: park-administrative-interface#0.1.1
6 verbose lifecycle park-administrative-interface#0.1.1~prestart: unsafe-perm in lifecycle true
7 verbose lifecycle park-administrative-interface#0.1.1~prestart: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\dba\Downloads\Park\park-administrative-interface\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\nodejs\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\dba\.windows-build-tools\python27;C:\Users\dba\.windows-build-tools\python27\Scripts;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files\PuTTY\;C:\RailsInstaller\Git\cmd;C:\RailsInstaller\Ruby1.9.3\bin;C:\Users\dba\AppData\Roaming\npm
8 verbose lifecycle park-administrative-interface#0.1.1~prestart: CWD: C:\Users\dba\Downloads\Park\park-administrative-interface
9 silly lifecycle park-administrative-interface#0.1.1~prestart: Args: [ '/d /s /c', 'npm install' ]
10 silly lifecycle park-administrative-interface#0.1.1~prestart: Returned: code: 1 signal: null
11 info lifecycle park-administrative-interface#0.1.1~prestart: Failed to exec prestart script
12 verbose stack Error: park-administrative-interface#0.1.1 prestart: `npm install`
12 verbose stack Exit status 1
12 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:285:16)
12 verbose stack at emitTwo (events.js:126:13)
12 verbose stack at EventEmitter.emit (events.js:214:7)
12 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
12 verbose stack at emitTwo (events.js:126:13)
12 verbose stack at ChildProcess.emit (events.js:214:7)
12 verbose stack at maybeClose (internal/child_process.js:925:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
13 verbose pkgid park-administrative-interface#0.1.1
14 verbose cwd C:\Users\dba\Downloads\Park\park-administrative-interface
15 verbose Windows_NT 6.1.7601
16 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
17 verbose node v8.10.0
18 verbose npm v5.6.0
19 error code ELIFECYCLE
20 error errno 1
21 error park-administrative-interface#0.1.1 prestart: `npm install`
21 error Exit status 1
22 error Failed at the park-administrative-interface#0.1.1 prestart script.
22 error This is probably not a problem with npm. There is likely additional logging output above.
23 verbose exit [ 1, true ]
I'm new with node.js and don't understand it very much. Thanks.
------------------------------------------------------------------------------
package.json content:
{
"author": "Claudinei Callegari",
"name": "park-administrative-interface",
"version": "0.1.1",
"private": true,
"contributors": [
{
"name": "Marcel Araujo",
"email": "admin#marcelaraujo.me"
}
],
"bugs": {
"url": ""
},
"license": "MIT",
"engines": {
"node": ">= 0.6.x"
},
"scripts": {
"postinstall": "bower install",
"prestart": "npm install",
"start": "./node_modules/http-server/bin/http-server build -a 0.0.0.0 -p 8000 -c-1",
"pretest": "npm install",
"test": "karma start karma.conf.js",
"test-single-run": "karma start karma.conf.js --single-run",
"protractor": "protractor e2e-tests/protractor.conf.js"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-bower-task": "^0.4.0",
"grunt-check-gems": "0.0.2",
"grunt-concurrent": "^1.0.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0",
"grunt-contrib-connect": "^0.8.0",
"grunt-contrib-copy": "^0.6.0",
"grunt-contrib-cssmin": "^0.10.0",
"grunt-contrib-jshint": "^0.10.0",
"grunt-contrib-sass": "^0.8.1",
"grunt-contrib-uglify": "^0.6.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-html-minify": "^0.3.1",
"grunt-html2js": "^0.2.9",
"grunt-ng-annotate": "^0.4.0",
"grunt-nodemon": "^0.3.0",
"grunt-parallel": "^0.3.1",
"grunt-s3": "^0.2.0-alpha.3",
"grunt-shell": "^1.1.1",
"http-server": "^0.7.3",
"load-grunt-tasks": "^0.6.0",
"time-grunt": "^1.0.0"
}
}

Resources