I'm trying to setup my app to use aot and also uglify. I can compile it using --bundle, but as soon as I add --env.aot or --env.uglify I can't get it to compile. With AOT I've quashed almost all of the errors. The only error I see is that it can't find a template and the path is wrong. I don't get it, though. I'm using a relative path with module.id.
#Component({
moduleId: module.id,
selector: 'test-radio',
templateUrl: './test-radio.component.html',
styleUrls: ['./test-radio.component.css']
})
The error when I build is:
JavaScript error:
file:///app/vendor.js:128056:103: JS ERROR Error: Could not resolve
test-radio.component.html. Looked for:
/Users/brice/Library/Developer/CoreSimulator/Devices/61560E27-9F8D-
430F-81D9-437A2E329F52/data/Containers/Bundle/Application/74041BF3-
8493-4EF2-BE46-F72257CC5C83/class2tns.app/app/test-radio.component.html.
But before that error, there is all this stuff:
ERROR in : Error: Cannot find module '#ngtools/webpack/src/utils'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (/Users/brice/source/class2tns/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.getResolvedEntryModule (/Users/brice/source/class2tns/node_modules/nativescript-dev-webpack/utils/transformers-utils.js:10:35)
at standardTransform (/Users/brice/source/class2tns/node_modules/nativescript-dev-webpack/transformers/ns-replace-bootstrap.js:16:50)
at transformer (/Users/brice/source/class2tns/node_modules/#ngtools/webpack/src/transformers/make_transform.js:21:25)
at /Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:1390:86
at reduceLeft (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:1102:30)
at /Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:1390:42
at transformRoot (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:81154:82)
at Object.map (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:429:29)
at Object.transformNodes (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:81141:30)
at emitJsFileOrBundle (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:81497:32)
at emitSourceFileOrBundle (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:81465:13)
at forEachEmittedFile (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:81373:30)
at Object.emitFiles (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:81454:9)
at emitWorker (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:86927:33)
at /Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:86887:66
at runWithCancellationToken (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:86979:24)
at Object.emit (/Users/brice/source/class2tns/node_modules/typescript/lib/typescript.js:86887:20)
at defaultEmitCallback (/Users/brice/source/class2tns/node_modules/#angular/compiler-cli/src/transformers/program.js:67:24)
at AngularCompilerProgram._emitRender2 (/Users/brice/source/class2tns/node_modules/#angular/compiler-cli/src/transformers/program.js:388:34)
at AngularCompilerProgram.emit (/Users/brice/source/class2tns/node_modules/#angular/compiler-cli/src/transformers/program.js:212:22)
at AngularCompilerPlugin._emit (/Users/brice/source/class2tns/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:850:49)
at Promise.resolve.then.then.then (/Users/brice/source/class2tns/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:676:54)
at process._tickCallback (internal/process/next_tick.js:68:7)
Running:
NativeScript CLI version: 5.4.1
CLI extension nativescript-cloud version: 1.17.6
CLI extension nativescript-starter-kits version: 0.3.5
Related
Problem
I'm trying to add a GraphQL client to an existing Vue3 project though it is causing the Mocha tests to fail. Running yarn test:unit results in the following error:
MOCHA Testing...
RUNTIME EXCEPTION Exception occurred while loading your tests
Error: Cannot find module './version.mjs'
Require stack:
- /home/chris/Projects/bottomtime/web-vue-gql/dist/js/main.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mocha/lib/mocha.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mocha/index.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/lib/cli/argsParser/parseArgv/mocha/parseMochaArgs.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/lib/cli/argsParser/parseArgv/index.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/lib/cli/index.js
- /home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/bin/mochapack
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function._resolveFilename (/home/chris/Projects/bottomtime/web-vue-gql/node_modules/mochapack/src/util/registerRequireHook.ts:21:34)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Module.<anonymous> (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/node_modules/graphql/index.mjs:29:1)
at __webpack_require__ (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/webpack/bootstrap:19:1)
at Object.defineProperty.value (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/src/index.ts:1:1)
at __webpack_require__ (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/webpack/bootstrap:19:1)
at Object.defineProperty.value (/home/chris/Projects/bottomtime/web-vue-gql/dist/js/webpack:/web-vue-gql/node_modules/vue-loader/dist/index.js:3:1)
[=========================] 100% (completed)
ERROR Error: mochapack exited with code 1.
Error: mochapack exited with code 1.
at ChildProcess.<anonymous> (/home/chris/Projects/bottomtime/web-vue-gql/node_modules/#vue/cli-plugin-unit-mocha/index.js:86:18)
at ChildProcess.emit (node:events:539:35)
at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
error Command failed with exit code 1.
Steps to Reproduce
Use the Vue CLI to scaffold a new project. (vue create project-name). For the options select "Manually select features", then enable all of the plugins, choose Vue v3.x, and choose Mocha + Chai as the unit test framework. (For all of the other questions you can just select the default.)
Once the project is scaffolded, cd into the directory and install GraphQL: yarn add graphql graphql-tag.
Add a query definition to any of the src/ files that would be loaded when the tests run. The problem specifically arises when using the gql function from the graphql-tag package. (You can grab my copy/paste-friendly example below!)
Run yarn test:unit and behold the above error.
Example GQL Code That Would Trigger the Failure
import { gql } from "graphql-tag";
gql`
query SomeQuery {
getCurrentUser {
username
}
}
`;
Notes
I've tried replacing Mocha/Chai w/ Jest to see if the problem persisted. It worked fine under Jest. That said, I'm adding GraphQL to an existing project and porting all of the tests to Jest is not exactly a great option.
I am on windows 10, using vscode. Basically finished the petshop tutorial with no issues or problems using truffle.
when I enter the command npm run dev it fails as shown below.
PS Y:\code\petshop> npm run dev
> pet-shop#1.0.0 dev
> lite-server
internal/modules/cjs/loader.js:316
throw err;
^
Error: Cannot find module 'Y:\code\petshop\node_modules\immutable\dist\immutable'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:308:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:521:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:872:27)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (Y:\code\petshop\node_modules\browser-sync\dist\hooks.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32) {
code: 'MODULE_NOT_FOUND',
path: 'Y:\\code\\petshop\\node_modules\\immutable\\package.json',
requestPath: 'immutable'
}
Not sure where to go from here, nothing works. This type of error is a bit beyond me. Any and all help is greatly appreciated.
EDIT: changed screenshot to code snippet. And I realized the problem is that the 'immutable' path is non-existent in my node_modules. Still not sure how to address this. tried a cheeky npm install immutable to no avail....
While testing the lambda function in api gateway i get below error message.
Let me give some some background here that what I'm doing.
I've created a stack which is creating apigateway, lambda and dynamo db.
The project has serverless.yml consisting of below configurations
I'm new to this setup and what I understand is that I'll have to install serverless framework (may with "sudo npm -i -g serverless") on lambda. Could you help me understanding where and how can I get this done OR is it something which Developers has to take care of?
Please let me know if you any other details.
serverless.yml
service: ps-hbo-api
plugins: ${file(./serverless-${self:provider.stage}.yml):plugins}
custom: ${file(./serverless-${self:provider.stage}.yml):custom}
vfg: ${file(./serverless-${self:provider.stage}.yml):vfg}
logs: ${file(./serverless-${self:provider.stage}.yml):logs}
serverless-prod.yml
plugins:
- serverless-prune-plugin
- serverless-pseudo-parameters
#Testing otherwise has to be removed
- serverless-http
index.js
const serverless = require('serverless-http');
const bodyParser = require('body-parser');
const express = require('express');
const app = express();
Error message
{"errorType":"Runtime.ImportModuleError","errorMessage":"Error: Cannot find module 'serverless-http'\nRequire stack:\n- /var/task/index.js\n- /var/runtime/UserFunction.js\n- /var/runtime/index.js","trace":["Runtime.ImportModuleError: Error: Cannot find module 'serverless-http'","Require stack:","- /var/task/index.js","- /var/runtime/UserFunction.js","- /var/runtime/index.js"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)"," at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)"," at Module._compile (internal/modules/cjs/loader.js:999:30)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)"," at Function.Module._load (internal/modules/cjs/loader.js:708:14)"," at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js [TRUNCATED]
Fri May 14 07:53:59 UTC 2021 : Lambda execution failed with status 200 due to customer function error: Error: Cannot find module 'serverless-http'
Require stack:
- /var/task/index.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js. Lambda request id: 2fe67c72-8d94-4011-b274-c7c91f10cdcf
Fri May 14 07:53:59 UTC 2021 : Method completed with status: 502
It looks like after you are deploying your lambda functions, it was not able to find the serverless-http npm dependency. Hence, I would recommend adding the serverless-plugin-include-dependencies plugin in your serverless-prod.yml so that it downloads and install the necessary dependencies while deploying your project.
After adding the plugin, here's how it should look like.
plugins:
- serverless-prune-plugin
- serverless-pseudo-parameters
- serverless-plugin-include-dependencies
You can check the details of the dependency plugin here from the serverless documentation.
I deployed some changes to a TypeScript project using serverless, I added this code and called it elsewhere:
import Mixpanel = require('mixpanel')
export default Mixpanel.init(process.env.MIXPANEL_TOKEN)
When I now invoke the AWS Lambda function, I receive this error message in my logs:
Unable to import module 'src/index': Error at Function.Module._load (module.js:438:3)
How can I find out more about the error?
Adding the MIXPANEL_TOKEN environment variable to the serverless.yml fixed this:
service: my-service
plugins:
- serverless-plugin-typescript
- serverless-offline
- serverless-prune-plugin
...
functions:
my-function:
handler: src/index.default
events:
- http:
path: /
method: post
environment:
MIXPANEL_TOKEN: ${env:MIXPANEL_TOKEN}
...
I created an asp.net core 2.0 project via
dotnet new reactredux -n sample
then I imported a new module named "react-bootstrap" via npm install
npm install --save #types/react-bootstrap
everything is good so far, but if I try to run this project on my local.
I got this error
An unhandled exception occurred while processing the request.
NodeInvocationException: Prerendering failed because of error: Error: Cannot find module "react-bootstrap"
at Object.<anonymous> (e:\git\Sample\ClientApp\dist\main-server.js:883:7)
at __webpack_require__ (e:\git\Sample\ClientApp\dist\main-server.js:20:30)
at Object.<anonymous> (e:\git\Sample\ClientApp\dist\main-server.js:327:84)
at __webpack_require__ (e:\git\Sample\ClientApp\dist\main-server.js:20:30)
at Object.<anonymous> (e:\git\DotNetCoreFans\ClientApp\dist\main-server.js:384:66)
at __webpack_require__ (e:\git\Sample\ClientApp\dist\main-server.js:20:30)
at e:\git\Sample\ClientApp\dist\main-server.js:66:18
at Object.<anonymous> (e:\git\Sample\ClientApp\dist\main-server.js:69:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
Current directory is: e:\git\Sample
Does anyone how to fix it?