I am trying to run a Testcafe test but get the following Error. This used to work until I recently updated npm and Node.
npm test
> e2e-tests#1.0.0 test
> node index.js test
TypeError: details.family.toLowerCase is not a function
at C:\mac\github\e2e-tests\node_modules\ip\lib\ip.js:385:39
at Array.filter (<anonymous>)
at C:\mac\github\e2e-tests\node_modules\ip\lib\ip.js:384:37
at Array.map (<anonymous>)
at ip.address (C:\mac\e2e-tests\node_modules\ip\lib\ip.js:379:37)
at Proxy.getIPAddress (C:\mac\e2e-tests\node_modules\endpoint-utils\index.js:109:15)
at getValidHostname (C:\mac\e2e-tests\node_modules\testcafe\lib\index.js:26:34)
at createTestCafe (C:\mac\e2e-tests\node_modules\testcafe\lib\index.js:71:9)
at async run (C:\mac\e2e-tests\test-runner.js:40:20)
at async testRunner (C:\mac\e2e-tests\test-runner.js:117:10)
at async start (C:\mac\e2e-tests\index.js:9:22)
This appears to be a bug with version 18 of node, interacting with the ip package (used in lots of popular libraries like Storybook and next ui).
You can try over-riding to use the latest version of ip:
{
"overrides": {
"ip": "1.1.8"
}
}
But - in my case at least - I ran into further issues with that approach. The only "fix" for now is to downgrade to use the long-term support (LTS) version of node/npm (currently 16.15.1) rather than 17/18. I highly recommend nvm, which will let you just do nvm install lts.
Related
I'm building my app by running npm run build and it errors out
with this output:
/home/markalexa/blog/client/node_modules/react-dev-utils/node_modules/globby/index.js:47
...taskOptions,
^^^
SyntaxError: Unexpected token ...
it points to this code block in index.js within the node_modules directory:
const generateGlobTasks = (patterns, taskOptions) => {
patterns = arrayUnion([].concat(patterns));
assertPatternsInput(patterns);
checkCwdOption(taskOptions);
const globTasks = [];
taskOptions = {
...taskOptions, // <--
ignore: [],
expandDirectories: true
};
The build has problem with the spread operator for some reason. Can you give me
any pointers to how to fix this ? I'm not really a npm developer.
node version: 6.11.4
npm version: 6.14.11
Thank you.
Edit:
After updating node to 8.6 which bumped up version of V8 as well
I'm getting this after running npm run build:
/home/markalexa/blog/client/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
Upgrading Node to 10.19 solved the problem. Looks like if you're not using
one of the most recent releases javascript code will break.
I was using node v6 for working on another project. Using nvm, I switched to node v14 and the issue was resolved.
I have this error when I run npm run dev or npm run watch and I didn't find what is the mess. It's happens in a all fresh Laravel 8 app.
It looks like happen when I use the developement command
ERROR in ./resources/css/app.css
Module build failed (from ./node_modules/css-loader/index.js):
ModuleBuildError: Module build failed (from ./node_modules/postcss-loader/src/index.js):
TypeError: [(...variantsValue),(...extensions)].flat is not a function
at /var/www/html/smart_recipe/node_modules/tailwindcss/lib/util/resolveConfig.js:219:73
at baseMergeDeep (/var/www/html/smart_recipe/node_modules/lodash/_baseMergeDeep.js:42:7)
at /var/www/html/smart_recipe/node_modules/lodash/_baseMerge.js:27:7
at /var/www/html/smart_recipe/node_modules/lodash/_createBaseFor.js:17:11
at baseMerge (/var/www/html/smart_recipe/node_modules/lodash/_baseMerge.js:24:3)
at /var/www/html/smart_recipe/node_modules/lodash/mergeWith.js:36:3
at /var/www/html/smart_recipe/node_modules/lodash/_createAssigner.js:30:9
at apply (/var/www/html/smart_recipe/node_modules/lodash/_apply.js:15:25)
at /var/www/html/smart_recipe/node_modules/lodash/_overRest.js:32:12
at mergeVariantExtensions (/var/www/html/smart_recipe/node_modules/tailwindcss/lib/util/resolveConfig.js:218:33)
at resolveVariants (/var/www/html/smart_recipe/node_modules/tailwindcss/lib/util/resolveConfig.js:235:10)
at resolveConfig (/var/www/html/smart_recipe/node_modules/tailwindcss/lib/util/resolveConfig.js:271:15)
at /var/www/html/smart_recipe/node_modules/tailwindcss/lib/index.js:77:37
at /var/www/html/smart_recipe/node_modules/tailwindcss/lib/processTailwindFeatures.js:52:20
at LazyResult.run (/var/www/html/smart_recipe/node_modules/postcss/lib/lazy-result.js:288:14)
at LazyResult.asyncTick (/var/www/html/smart_recipe/node_modules/postcss/lib/lazy-result.js:212:26)
at LazyResult.asyncTick (/var/www/html/smart_recipe/node_modules/postcss/lib/lazy-result.js:225:14)
at /var/www/html/smart_recipe/node_modules/postcss/lib/lazy-result.js:217:17
at runLoaders (/var/www/html/smart_recipe/node_modules/webpack/lib/NormalModule.js:316:20)
at /var/www/html/smart_recipe/node_modules/loader-runner/lib/LoaderRunner.js:367:11
at /var/www/html/smart_recipe/node_modules/loader-runner/lib/LoaderRunner.js:233:18
at context.callback (/var/www/html/smart_recipe/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
at Promise.resolve.then.then.catch (/var/www/html/smart_recipe/node_modules/postcss-loader/src/index.js:208:9)
# ./resources/css/app.css
I came across same issue and spent 5 hours on finding solution but could not.
After searching alot, I came across this
"Tailwind CSS v2.0 no longer supports Node.js 8 or 10. To build your CSS you'll need to ensure you are running Node.js 12.13.0 or higher in both your local and CI environments."
at https://tailwindcss.com/docs/upgrading-to-v2
So I realized that issue was in my Node version which was 10.x so
I uninstalled Node from my windows machine and downloaded LTS version (14.x).
So consider updating your Node version, it will solve the issue as it did work for me.
There is possibility that old node versions don't have that flat function that Tailwind CSS 2 has implemented and that's throwing error.
I Had the exact same issue after installing Breeze... Unfortunately the npm error message gives no clue of what is really going on !
Thanks to #DaniyalGondal I found out that my node version was raising the error because of tailwind V2 requirements (https://tailwindcss.com/docs/upgrading-to-v2) that comes with Breeze... So I did upgrade my node version using : sudo n latest under ubuntu20
Don't forget to restart your terminal after upgrading and check that your node is correctly upgraded using : node --version
If the node version is above 12.13.0, now npm run watch or npm run dev should work fine !
When running my test suite using Jest, I encountered warnings that asked me to update packages:
npm WARN deprecated jest-dom#2.1.1: 🚨 jest-dom has moved to #testing-library/jest-dom. Please uninstall jest-dom and install #testing-library/jest-dom instead, or use an older version of jest-dom. Learn more about this change here: https://github.com/testing-library/dom-testing-library/issues/260 Thanks! :)
npm WARN deprecated react-testing-library#5.9.0: 🚨 react-testing-library has moved to #testing-library/react. Please uninstall react-testing-library and install #testing-library/react instead, or use an older version of react-testing-library. Learn more about this change here: https://github.com/testing-library/dom-testing-library/issues/260 Thanks! :)
In package.json I changed the following
"jest-dom": "^2.1.1",
"react-testing-library": "^5.3.0"
to
"#testing-library/jest-dom": "^5.11.1",
"#testing-library/react": "^10.4.7"
and of course the import statements from
import "jest-dom/extend-expect";
to
import "#testing-library/jest-dom";
etc.
After I removed the old ones and added the new one, I got multiple error that makes my tests fail (only in my Semaphore CI setup, not on my local machine).
FAIL src/redux/actions/tests/myActions.test.js
● Test suite failed to run
Jest encountered an unexpected token
This usually means that you are trying to import a file which Jest cannot parse, e.g. it's not plain JavaScript.
By default, if Jest sees a Babel config, it will use that to transform your files, ignoring "node_modules".
Here's what you can do:
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/en/configuration.html
Details:
/home/semaphore/my-app/client/node_modules/#testing-library/dom/dist/helpers.js:44
} catch {// not using Jest's modern fake timers
^
SyntaxError: Unexpected token {
at ScriptTransformer._transformAndBuildScript (node_modules/jest-runtime/build/script_transformer.js:403:17)
at Object.<anonymous> (node_modules/#testing-library/dom/dist/pretty-dom.js:13:16)
at Object.<anonymous> (node_modules/#testing-library/dom/dist/config.js:11:18)
I am not a frontend developer, so I am happy to hear what more information is needed to facilitate help. Thanks a lot!
The error refers to optional catch binding, which is modern JS feature and supported since Node 10. This means that #testing-library/dom package doesn't support older Node versions, this can be confirmed by checking engines section in its package.json.
A preferable solution is to update Node.js because 8 reached the end of life. Alternatively, the package can be downgraded to lower major version or transpiled by white-listing it in transformIgnorePatterns, as the error suggests.
#Estus's answer is absolutely right, and I voted it up. Just wanted to add the actual fix if you are also using Semaphore for your CI, so you don't need to spend more time investigating like I did.
Make sure your current node version is at least the latest stable LTS, and that the version you're using locally is the version your tests pass with
Generate an .nvmrc file if you don't have one already: node -v > .nvmrc
Make sure you call nvm use in every block of your semaphore.yml.
i.e. use an extrapolated for-your-project, version of this: https://github.com/semaphoreci-demos/semaphore-demo-javascript/blob/master/.semaphore/semaphore.yml.
That will ensure your node versions are in sync, and should resolve any "SyntaxError: Unexpected token {" errors you're encountering in CI provided the same tests are passing locally. If you don't specify the node version, Semaphore uses v8.17.0 as the default (https://docs.semaphoreci.com/ci-cd-environment/ubuntu-18.04-image/#javascript-via-node-js)! Hence why anyone who doesn't specify the version will encounter this error when upgrading any Jest libs.
I have problem with test cases running. actually I upgrade node dependency from old version to new version also node version v6 to v10, Before update npm module my code was working fine. But I do not known what issue happen now.
Please help me out that..!
I'm using ttest nodejs module in application. Due to updates to it I tried to use updated version ttest#2.0.0. When module start compute data the error appears:
ReferenceError: WebAssembly is not defined
The NodeJS version - 6.9.1.
Error appears in next place:
class CephesWrapper {
constructor(sync) {
// Initialize the runtime's memory
this._wasmMemory = new WebAssembly.Memory({
'initial': TOTAL_MEMORY / WASM_PAGE_SIZE,
'maximum': TOTAL_MEMORY / WASM_PAGE_SIZE
});
.....
}
}
Is there any advices about solving this issue? Is it possible to define WebAssembly?
The WebAssembly support is added in NodeJs 8.0.0. Update your NodeJS to make it work.
In my case, the problem was that I was running my browser in safe mode (Mozilla Firefox).
Simply shutdown your browser completely and restart. This will quit safe mode (If stuck in safe mode, see here)
For reference, I had found this solution here : https://github.com/mozilla-iot/gateway/issues/2047
Even my node version was 12, and npm version was 6. I was getting the reference error for webassembly.
So I updated the node with latest version(16), it changed the npm version also. Now the reference issue is fixed.
D:\ReactJS\react_demo>node -v
v16.14.0
D:\ReactJS\react_demo>npm -v
8.3.1