I've started having problems getting nativescript to run, and the error message is truly confusing, since it is exit code 0.
tns run android
Searching for devices...
NativeScript Environment: tns run <platform> --env not provided.
NativeScript Environment: Environment vars not changed
Preparing project...
File change detected. Starting incremental webpack compilation...
webpack is watching the files…
Executing webpack failed with exit code 0.
I've tried the usual suspect list of remedies: uninstall/reinstall nativescript, platforms, etc. tns doctor gives me a full green-checkmark bill of clean health.
This just started happening today. I've been using it without this problem for over a year of development prior.
What should I try next?
Well, this is working again now for me.
Here's what I found:
I found I was able to build a different project without issue, but not my main work.
After other messing about, I finally was given an error message that complained that my webpack.config.js was different than that of one of my plugins. It suggested I run ./node_modules/.bin/update-ns-webpack --configs to revert to an approved configuration.
I did that, and it worked. However, I had deliberately modified my webpack config some time ago to allow some app-specific files to transfer, as shown below.
I put my custom 'globs' lines back in and it still works, although this is the same as where it was when the whole affair started.
go figure.
// Copy assets to out dir. Add your own globs as needed.
new CopyWebpackPlugin([
{ from: { glob: "fonts/**" } },
{ from: { glob: "**/*.jpg" } },
{ from: { glob: "**/*.png" } },
{ from: { glob: "**/*.json" } },
{ from: { glob: "**/*.map" } }
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),
(the *.json and *.map entries are my additions). As the comment implies, this appears to be an encouraged form of config modification for this purpose.
Related
I am building a Nuxt3 app and trying to integrate Cypress. As I'm aware Nuxt3 uses Vite instead and not babel, I was trying to instrument the project code using vite-plugin-istanbul npm package.
Here's my nuxt.config.ts after installing vite-plugin-istanbul package:
vite: {
vue: {
template: {
transformAssetUrls: true
}
},
plugins: [
istanbul({
exclude: ['node_modules', 'test/', 'coverage/'],
extension: [ '.js', '.ts', '.vue' ],
cypress: true
}),
]
},
When I'm trying to run the server using npm run dev and visit the localhost URL, the following error is thrown at terminal:
[nuxt] [request error] [unhandled] [500] window is not defined
at cov_1291n0zka8 (./.nuxt/dist/server/server.mjs:3623:191)
at $id_Sv05hbOoTf (./.nuxt/dist/server/server.mjs:3624:75)
at async __instantiateModule__ (./.nuxt/dist/server/server.mjs:40418:3)
It seems the plugin is instrumenting the server-side rendered code and window object isn't defined there. I need to have SSR enabled in my app and I'm not sure of how to handle this error.
This issue has been resolved by the plugin authors.
TLDR version
Just update the vite-plugin-istanbul package to the latest version and the issue should get resolved.
Long version
There are two parts to this error:
The package was originally configured to transform all the files. The plugin authors have now added a condition that checks whether the SSR has been enabled or not. This is done via options.ssr property within the transform function. Please upgrade to the latest version of vite-plugin-istanbul. The plugin no longer instruments the SSR files, hence the window object error no longer exists in there. Follow this thread if you need more details.
After getting this error resolved, I was still facing another issue where the code instrumentation was impacting the proper app compilation and throwing a hydration mismatch error. The plugin authors came to the rescue again and fixed this error. Please upgrade to the latest version of vite-plugin-istanbul. Follow this GitHub thread if you need more details.
The package authors are really awesome and helpful. It's great to see such people in the open source community!
Im on a M1 apple, so node-sass wont work for me. Every site I work on, I uninstall node-sass and install sass( also change nvm use 16.2.0 if anyone has that issue).
this has always worked, but today after doing so I get the following errors
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Cannot find module 'node-sass'
So I went into node_modules/sass-loader/lib/loader.js and found this on line 46
const render = getRenderFuncFromSassImpl(options.implementation || require("node-sass"));
and changed it to
const render = getRenderFuncFromSassImpl(options.implementation || require("sass"));
Everything works, css is compiled.. but what I did seems like a hack,
Is there a better way to do it?
Will this break things in future?
Why didn't it update automatically like the other 20 sites I work on?
You can set the implementation of sass-loader in your package.json so it will use value of options.implementation instead of require("node-sass"):
module.exports = {
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
"style-loader",
"css-loader",
{
loader: "sass-loader",
options: {
// Prefer `dart-sass`
implementation: require("sass"),
},
},
],
},
],
},
};
As for your third question, the doc states that:
By default the loader resolve the implementation based on your dependencies. Just add required implementation to package.json (sass or node-sass package) and install dependencies.
Maybe you still have node-sass listed as a dependency?
I struggled with the same problem. What ended up working was to delete package-lock.json and install everything again.
I am using yarn 2 and react with webpack.
In my package is "typescript": ... defined. Once I start yarn start I am getting an error:
yarn workspace test start
When you use this plugin you must install `typescript`.
What is wrong? How should I fix it? Or debug it?
I've faced the similar issue when I was upgrading webpack from 4 to 5.
The problem was the version of react-dev-utils
Upgrading react-dev-utils from v10 to v12 made the issue disappear.
devDependencies {
...
"react-dev-utils": "^12.0.1",
...
}
You can be checked the value of your plugins config about ForkTsCheckerWebpackPlugin which the param key named tsconfig.
Error Message
Check [key, value] about ForkTsCheckerWebpackPlugin.
Find it in your node_modules, and set debug point, run the debugger.
You need to take a look at your webpack.config.js where ForkTsCheckerWebpackPlugin is initialized. ForkTsCheckerWebpackPlugin needs to be able to find the tsconfig file.
new ForkTsCheckerWebpackPlugin({
typescript: resolve.sync('typescript', {
basedir: paths.appNodeModules,
tsconfig: paths.appTsConfig,
})
}),
In my case I'm defining paths.appNodeModules and paths.appsTsConfig in a file called paths.js.
module.exports = {
appTsConfig: resolveApp('tsconfig.json'),
appNodeModules: resolveApp('node_modules'),
};
I'm setting up linting with golangci-lint in my Go project. I have a file generated by go-bindata that VSCode is listing the following under the Problems tab:
assets/assets.go: redundant type from array, slice, or map composite literal (simplifycompositelit)
I can't seem to get rid of it. It's not a compiler error and I'll be re-running go-bindata from time to time so I don't want to make a habit of modifying generated code.
Right now, with the configuration below, I can't make VSCode stop reporting this error. If I run golangci-lint run ./... in the root of the workspace I get no output. I can provide my linting config if needed but VSCode seems to be running something else. How do I figure out what's reporting this error and how do I make it stop reporting anything for the file assets/assets.go in this one workspace?
Here's Go-related vscode settings:
{
"go.formatTool": "gofmt",
"go.lintTool": "golangci-lint",
"go.liveErrors": {
"enabled": true,
"delay": 500
},
"go.lintOnSave": "workspace",
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"go.useLanguageServer": true,
"go.languageServerExperimentalFeatures": {
"diagnostics": true,
"documentLink": true
},
}
Here's the line in question even with a nolint comment to show it's not behaving as expected. If it were golangci-lint outputting this, the nolint would prevent the warning from showing. I reloaded the window and closed/reopened vscode to be sure the change was noticed.
After reproducing locally, it seems this message comes from gopls, as disabling gopls silences the message. There are a couple of related complaints/issues on the Go issue tracker:
hide gofmt -s diagnostics (and others?) in generated files
should not issue lint-style warnings on generated code
Neither offers an actual solution.
However, this issue on the vscode-go repo, provides a work-around. In your VSCode config, add the gopls.analyses.simplifycompositelit key, with a value of false:
"gopls": {
"analyses": {
"simplifycompositelit": false
},
}
Of course, this disables it for all projects, not just generated files, but if you're also using golangci-lint, it can be configured to catch the same types of errors, and can be configured on a more granular basis, so that you won't miss the same class of errors in non-generated code.
I'm making a simple app that uses nativescript-audio and I want to play some mp3 samples in the app. The problem is, when I click "Run on Device" in Sidekick, it doesn't transfer any mp3 files I included in the app folder (and therefore I can't play it). What is weird is that if I just change the extension of the file (for example to .jpg), the transfer works fine (and I can even play that file as if it was mp3).
So, just to exemplify the problem, if I use this code, it doesn't work:
const audio = require('nativescript-audio');
const player = new audio.TNSPlayer();
const playerOptions = {
audioFile: '~/audio/myfile.mp3',
loop: false
};
But if I just rename "myfile.mp3" to "myfile.jpg", change the code like this:
...
audioFile: '~/audio/myfile.jpg',
...
and then rebuild the app, it works just fine and plays the sample that was originally stored in myfile.mp3 and is now stored in myfile.jpg.
Using file-system I can also detect the .jpg file is present but .mp3 is not.
What I want to ask is whether Sidekick looks only for certain file extensions and ignores the others during build, and whether I can change the "watched file extensions" setting.
I guess you are running with webpack, the default webpack configuration will copy only fonts and images (JPEG / PNG etc.,) along with your source code. If you have any other files to be copied modify the copy plugin configurations inside webpack.config.js something like,
new CopyWebpackPlugin([
{ from: "fonts/**" },
{ from: "songs/**" },
{ from: "**/*.jpg" },
{ from: "**/*.png" },
{ from: "**/*.png" },
], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }),