I try to run in index.js of Cypress:
require('#cypress/code-coverage/task')
Getting this error:
Module not found: Error: Can't resolve '../self-coverage-helper' in 'C:\repo\patientstrength_codecover\node_modules\#cypress\code-coverage\node_modules\nyc'
Totally lost here. My package.json:
"nyc": "^15.1.0",
"cypress": "^5.0.0",
"cypress-istanbul": "^1.3.0",
"cypress-localstorage-commands": "^1.2.2",
"cypress-multi-reporters": "^1.2.4",
"#cypress/code-coverage": "^3.8.1",
"#babel/core": "^7.11.4",
"#babel/plugin-syntax-dynamic-import": "^7.8.3",
"#babel/plugin-syntax-jsx": "^7.10.4",
"#babel/preset-env": "^7.11.0",
"#babel/preset-react": "^7.10.4",
The issue was that we are using a "root" package.json with basic scripts like gulp, jest and well - also we tried to run Cypress from that root. And beside the coverage, it worked fine.
So we have:
/git/root/package.json
/git/root/solution1/package.json
/git/root/solution2/package.json
We solved the issue by simply install Cypress and all dependencies first (!) in the:
/git/root/solution1/package.json and /git/root/solution2/package.json solutions.
NOT in the /git/root/package.json.
The /git/root/package.json now only contains a script invoking the 2 Cypress installations. And later we merge the results. Sure some redundancy
The invoke script is as following:
"test:client1": "cd client1 && cd ClientApp && npm run coverage"
So very simple approach. What we couldn't solve is the redundancy regarding Cypress configuration and commands. That can be optimized.
Related
I cannot seem to build from github because of the below error.
Does anyone have an idea of the error and how to fix it?
Module not found: Error: You attempted to import /tmp/build_69fe27ea/node_modules/console-browserify/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
You can either move it inside src/, or add a symlink to it from project's node_modules/.
console-browserify is being imported by the node-polyfill-webpack-plugin
node-polyfill-webpack-plugin#^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/node-polyfill-webpack-plugin/-/node-polyfill-webpack-plugin-1.1.4.tgz#56bfa4d16e17addb9d6b1ef3d04e790c401f5f1d"
integrity sha512-Z0XTKj1wRWO8o/Vjobsw5iOJCN+Sua3EZEUc2Ziy9CyVvmHKu6o+t4gUH9GOE0czyPR94LI6ZCV/PpcM8b5yow==
dependencies:
assert "^2.0.0"
browserify-zlib "^0.2.0"
buffer "^6.0.3"
console-browserify "^1.2.0"
constants-browserify "^1.0.0"
crypto-browserify "^3.12.0"
domain-browser "^4.19.0"
events "^3.3.0"
filter-obj "^2.0.2"
https-browserify "^1.0.0"
os-browserify "^0.3.0"
path-browserify "^1.0.1"
process "^0.11.10"
punycode "^2.1.1"
querystring-es3 "^0.2.1"
readable-stream "^3.6.0"
stream-browserify "^3.0.0"
stream-http "^3.2.0"
string_decoder "^1.3.0"
timers-browserify "^2.0.12"
tty-browserify "^0.0.1"
url "^0.11.0"
util "^0.12.4"
vm-browserify "^1.1.2"
I was trying to update our production project which holds 500+ modules and we certainly need this tool to make it work because manually doing so would be a nightmare. I've been the whole afternoon trying to make it work even copying and pasting your import example and haven't manage to do so.
Our imports are like following in the whole project:
import {
NzTableModule,
NzCheckboxModule,
NzInputModule,
NzFormModule,
NzSelectModule,
NzDrawerModule,
NzDividerModule,
NzToolTipModule,
NzDatePickerModule,
} from 'ng-zorro-antd';
I'm using the following config:
{
"rulesDirectory": [
"nz-tslint-rules"
],
"rules": {
"nz-secondary-entry-imports": true
}
}
package.json:
"ng-zorro-antd": "^9.3.0",
"typescript": "~3.8.3",
"nz-tslint-rules": "^0.901.2",
"#angular/core": "~9.1.12",
I'm executing the following command from the app root:
"tslint --project ."
I've managed to be sure about the script execution with a console log in the nzSecondaryEntryImportsRule.js file
Also I've notice that:
tsutils.isImportDeclaration(node)
Always returns false therefore it continues to the next iteration in the for loop
I'd appreciate any help on this.
I guess because the global version is too low.
here are three solutions:
upgrade your global tslint
npm install tslint -g
add the command to the scripts in package.json, and then use npm run lint:fix
{
"scripts": {
"lint:fix": "tslint --project tsconfig.json --fix"
}
}
run from node_modules/.bin/tslint
node_modules/.bin/tslint --project tsconfig.json --fix
I have a yarn 2 workspaces project with two workspaces:
|-foo
\-bar
Now, in the root package.json, I pull in common dev-depenencies:
"devDependencies": {
"#rollup/plugin-commonjs": "^14.0.0",
"#rollup/plugin-node-resolve": "^8.4.0",
"#rollup/plugin-replace": "^2.3.3",
"#rollup/plugin-typescript": "^5.0.2",
"#types/jest": "^26.0.13",
"nollup": "^0.13.10",
"rimraf": "^3.0.2",
"rollup": "^2.23.1",
"ts-jest": "^26.3.0",
"tslib": "^2.0.1",
"typescript": "^4.0.2"
}
How can I easily (without too much boilerplate) now reference rollup, etc. from scripts in the package.json of foo and bar?
Example: foo/package.json
"build": "rollup ...",
Writing "../node_modules/.bin/rollup" sucks.
Note, I don't want to install rollup etc globally.
To run executable installed in root workspace, you can say:
"build": "run -T rollup",
-T is for --top-level and is not currently documented anywhere. I was informed about its existence on Yarn discord server by one of the maintainers.
https://github.com/yarnpkg/berry/blob/bef203949d9acbd42da9b47b2a2dfe3615764eaf/packages/plugin-essentials/sources/commands/run.ts#L47-L49
So, I found a not-too-bad solution. In the workspace root, I add some executable files for the commands I want to use in my scripts, e.g.:
tsc:
#!/bin/bash
$(dirname "${BASH_SOURCE[0]}")/node_modules/.bin/tsc -b -f "$#"
rollup:
#!/bin/bash
$(dirname "${BASH_SOURCE[0]}")/node_modules/.bin/rollup "$#"
These basically "forward" the call to the actual binaries and may add some common parameters.
In my foo/bar package.json, I can now reference those scripts:
"dev:compile": "../tsc",
"build": "../tsc && ../rollup -c rollup.config.js",
When I deploy my build, the build always succeeds and runs too. However a couple seconds after running it crashes with no logs about why. I have tested locally using the heroku local web command and it works flawlessly. I have also used heroku bash to check node_modules to ensure all my dependencies have been installed correctly. I also tried to run via heroku bash but the same error occured. Node and npm versions are the same on both local and remote with versions node: >=10.16.0 and npm: >= 6.9.0. I have attempted to also copy my files (excluding package-lock.json and node_modules) into a new directory and use npm install and npm run start and still works as intended locally. Any ideas?
Update
I rolled back to a previous commit that was working using the heroku's rollback command and the website is up and running. I create a staging branch and pushed my changes so I am now working off of that. The thing is I just wish there was some kind of error message in the logs that would specify why its crashing because this has left me stumped for days.
another update
I installed ubuntu to test running my project on a linux OS to see if that would repro this issue but it still ran as normal.
** Final Update **
I managed to get things working by completely starting from scratch and adding one thing at a time. I know this isnt helpful but I would like to keep this question open because I still do not know what caused this issue.
package.json
{
"name": "hayewoodbotapi-v2",
"version": "0.0.0",
"scripts": {
"start": "npm run prod",
"build": "npm-run-all clean transpile",
"server": "node ./dist-server/bin/www",
"prod": "npm-run-all build server",
"transpile": "webpack && babel server --source-maps --out-dir dist-server",
"clean": "rimraf dist-server"
},
"dependencies": {
"#babel/node": "^7.2.2",
"babel-loader": "^8.1.0",
"cookie-parser": "~1.4.4",
"crypto-js": "^4.0.0",
"debug": "~2.6.9",
"ejs": "^3.0.1",
"express": "^4.17.1",
"express-generator": "^4.16.1",
"express-session": "^1.17.0",
"http-errors": "~1.6.3",
"jade": "~1.11.0",
"lance-gg": "^4.0.8",
"morgan": "~1.9.1",
"nodemon": "^2.0.3",
"npm-run-all": "^4.1.5",
"passport": "^0.4.1",
"passport-oauth": "^1.0.0",
"passport-twitch": "^1.0.3",
"pg": "^7.18.2",
"query-string": "^6.12.0",
"regenerator-runtime": "^0.13.5",
"request": "^2.88.2",
"rimraf": "^3.0.2",
"sequelize": "^5.21.5",
"sequelize-cli": "^5.5.1",
"socket.io": "^2.3.0",
"webpack": "^3.8.1"
},
"engines": {
"node": ">=10.16.0",
"npm": ">=6.9.0"
},
"devDependencies": {
"#babel/cli": "^7.2.3",
"#babel/core": "^7.3.4",
"#babel/preset-env": "^7.3.4",
"eslint": "^3.16.1",
"express-swagger-generator": "^1.1.17"
}
}
Here are the logs via heroku. As you can see it is executing because I added a console.log statement to output the port.
2020-04-30T18:50:49.307843+00:00 app[web.1]: Successfully compiled 23 files with Babel.
2020-04-30T18:50:50.111523+00:00 app[web.1]:
2020-04-30T18:50:50.111537+00:00 app[web.1]: > hayewoodbotapi-v2#0.0.0 server /app 2020-04-30T18:50:50.111537+00:00 app[web.1]: > node ./dist-server/bin/www
2020-04-30T18:50:50.111538+00:00 app[web.1]:
2020-04-30T18:50:52.021984+00:00 app[web.1]: Warning: connect.session() MemoryStore is not
2020-04-30T18:50:52.021997+00:00 app[web.1]: designed for a production environment, as it will leak
2020-04-30T18:50:52.021998+00:00 app[web.1]: memory, and will not scale past a single process. 2020-04-30T18:50:52.028026+00:00 app[web.1]: PORT: 49175 2020-04-30T18:50:52.063057+00:00 app[web.1]: (node:138) [SEQUELIZE0004]
DeprecationWarning: A boolean value was passed to options.operatorsAliases.
This is a no-op with v5 and should be removed.
2020-04-30T18:50:52.063059+00:00 app[web.1]: (Use node --trace-deprecation ... to show where the
warning was created) 2020-04-30T18:50:52.243126+00:00 heroku[web.1]: State changed from starting to crashed
It turned out I just needed to upgrade node version and downgrade webpack version.
I have a project using nrwl/nx and I started the workspace(morningharwood) and an app(portfolio) on my home computer (windows). On the move, I've now cloned the repo, yarn install the deps and tried to run on my mac. Unfortunately, when running node_modules/.bin/ng serve --app=portfolio I get an error that Cannot find module 'typescript' from '/Users/m/projects' locally and globally i have typescript install:
Question: Why cant my project find typescript; How can I run my project on my mac?
m#mac: ~/projects/ on feature/prerender [?]
$ tsc -v
Version 2.6.1
m#mac: ~/projects/morningharwood/platform on feature/prerender [?]
$ node_modules/.bin/ng serve --app=portfolio
Cannot find module 'typescript' from '/Users/m/projects'
Error: Cannot find module 'typescript' from '/Users/m/projects'
at Function.module.exports [as sync] (/Users/m/projects/morningharwood/platform/node_modules/resolve/lib/sync.js:40:15)
at Object.requireProjectModule (/Users/m/projects/morningharwood/platform/node_modules/#angular/cli/utilities/require-project-module.js:6:28)
at Object.readTsconfig (/Users/m/projects/morningharwood/platform/node_modules/#angular/cli/utilities/read-tsconfig.js:6:48)
at new NgCliWebpackConfig (/Users/mharwood/projects/morningharwood/platform/node_modules/#angular/cli/models/webpack-config.js:19:42)
at Class.run (/Users/m/projects/morningharwood/platform/node_modules/#angular/cli/tasks/serve.js:71:29)
at check_port_1.checkPort.then.port (/Users/m/projects/morningharwood/platform/node_modules/#angular/cli/commands/serve.js:123:26)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)
m#mac: ~/projects/morningharwood/platform on feature/prerender [?]
package.json
"devDependencies": {
"ts-node": "^3.3.0",
"tsconfig-paths": "^2.3.0",
"tslint": "~5.3.2",
"typescript": "2.4.2",
}
This issue has be solved by issue 109
https://github.com/nrwl/nx/issues/109
Here's how you correct it:
The issue is because the root property in .angular-cli.json is set to
"root": "apps\portfolio\src", if you change it to
apps/portfolio/src, it will work. I'll fix it.
Should be corrected in the future releases of nrwl.