I'm running mocha tests and I recently upgraded to the newest version of the ask-cli. I ran the tests again and I'm now receiving this module error. I've npm installed src and utils to no avail. From what I've read it's possible module-alias does not support #src paths.
I'm calling this command:
$ ask api simulate-skill -l en-US -t "start my day" -s amzn1.ask.skill.XXXXXXXX-4156-4ca0-b14e-XXXXXXXXXXXX
Update: this seems to be an issue with the ask-cli which uses
const CONSTANTS = require('#src/utils/constants');
The #src should find the source of the node package but this #src is not used in any other packages I could find. All other packages seem to use ../../ so that's likely while module-alias does not find anything bc it doesn't know how to route this new syntax
Does anyone know of this new #src syntax and if there is a npm module for helping route it?
Which worked for ask-cli 1.1.6 but I upgraded to 1.7.2 for new functionality.
Error: Cannot find module '#src/utils/constants'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._resolveFilename (/Users/calebgates/WebstormProjects/AutomatedUtteranceTesting/node_modules/module-alias/index.js:49:29)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/calebgates/WebstormProjects/AutomatedUtteranceTesting/node_modules/ask-cli/lib/commands/init/index.js:1:81)
at Module._compile (module.js:652:30)
at Module.replacementCompile (/Users/calebgates/WebstormProjects/AutomatedUtteranceTesting/node_modules/nyc/node_modules/append-transform/index.js:58:13)
at module.exports (/Users/calebgates/WebstormProjects/AutomatedUtteranceTesting/node_modules/nyc/node_modules/default-require-extensions/js.js:8:9)
at Object.<anonymous> (/Users/calebgates/WebstormProjects/AutomatedUtteranceTesting/node_modules/nyc/node_modules/append-transform/index.js:62:4)
module.js:549
I solved this by including the ask-sdk in my local project's dependencies.
This is acknowledged bug when ask-cli is installed locally. There are two work-arounds pointed out in the bug report.
Either install ask-cli globally:
$ npm install -g ask-cli
Or install the module-alias package:
$ npm install module-alias
and configure it to look for #src in the ask-cli/lib folder by adding the following to your package.json file:
"_moduleAliases": {
"#src": "./node_modules/ask-cli/lib",
"#root": "./node_modules/ask-cli",
"#test": "./node_modules/ask-cli/test"
}
Related
I'm using MacOS monterey with M1 chip as my operating system. installed NestJS cli using this command: sudo npm install -g #nestjs/cli
when creating new nest project using nest new message everything works fine, but when I try to create new module using this command nest generate module messages I face error.
why does this happen? I tried installing schematics using npm i -g #nestjs/schematics, I don't know if I should've installed it but this didn't help anyway.
The error I face is:
/Users/homayoun/training/messages/node_modules/#angular-devkit/schematics-cli/bin/schematics.js:338
throw new Error(`Unknown argument ${key}. Did you mean ${(0, yargs_parser_1.decamelize)(key)}?`);
^
Error: Unknown argument skipImport. Did you mean skip-import?
at parseArgs (/Users/homayoun/training/messages/node_modules/#angular-devkit/schematics-cli/bin/schematics.js:338:19)
at main (/Users/homayoun/training/messages/node_modules/#angular-devkit/schematics-cli/bin/schematics.js:122:49)
at Object.<anonymous> (/Users/homayoun/training/messages/node_modules/#angular-devkit/schematics-cli/bin/schematics.js:367:5)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Failed to execute command: node #nestjs/schematics:module --name=messages --no-dry-run --no-skipImport --language="ts" --sourceRoot="src" --spec.
worth noting that I don't face any issues when I do the same thing on ubuntu 20 or 22
Quick solution:
add this to your nest-cli.json
"root": "src"
change into the src of your project folder
cd src
run
nest generate module messages
if the above does not work also try changing the version of packages in package.json to
"#nestjs/cli": "8.2.6",
"#nestjs/schematics": "8.0.11",
removing the node modules in the current project
reinstalling the nest cli with
npm uninstall -g #nestjs/cli
npm i -g #nestjs/cli#8.2.6
this is a bug on the latest version of #nestjs/cli (v8.2.7). Downgrade it to 8.2.6 and it will work (I tested it). It was reported here: https://github.com/nestjs/nest-cli/issues/1693
Also, I don't recommend using the global version of the CLI. Instead, use npx nest or yarn nest.
I am unable to successfully run npm start on an application I've created via create-react-app on Termux; I have not done any modifications from the base application beyond running rm -rf node-module followed by npm install in an unsuccessful bid to get it to work, I also tried npm install autoprefixer#9.8.0 to no avail. This is the error dump:
Error: Package exports for '/data/data/com.termux/files/home/…/node_modules/postcss-safe-parser/node_modules/postcss' do not define a valid '.' target
at resolveExportsTarget (internal/modules/cjs/loader.js:455:13)
at resolveExports (internal/modules/cjs/loader.js:388:16)
at Function.Module._findPath (internal/modules/cjs/loader.js:487:20)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:782:27)
at Function.Module._load (internal/modules/cjs/loader.js:688:27)
at Module.require (internal/modules/cjs/loader.js:850:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/data/data/com.termux/files/home/…/node_modules/postcss-safe-parser/lib/safe-parse.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:958:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:994:10) {
code: 'MODULE_NOT_FOUND'
}
…
I'm completely new to React, so any solutions would be appreciated. Thank you.
Well, it turns out the solution is to update the packages (presumably at least Node, although simply entering node install broke the installation) via pkg update; no more error.
This is my first post, so forgive me for formatting issues. I was following this mean.io tutorial: https://www.youtube.com/watch?v=0aMNWYpG5sk. It basically gets you to the point where you can locally access the default web app. I was able to do so successfully.The video then suggests to run>
mean package myTheme
I received this error...
C:\Users\****\myApp>mean package myTheme
module.js:339
throw err;
^
Error: Cannot find module 'config-chain'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object.<anonymous> (C:\Users\****\AppData\Roaming\npm\node_modules\mean-cli\node_modules\npm\lib\config\core.js:2:10)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
I'm running npm 2.14.7 and node v4.2.3(video uses 4.2.2) on Win 10. I had previously tried this on node 5.3 and received the same error. I also tried cleaning cache & updating npm, bower, and gulp.
I found C:\Users****\myApp\node_modules\config-chain. Do I need to change something here?
Any help would be greatly appreciated. If I need to provide more information, just ask. Thanks!
I guess something was wrong with mean-cli.
I reran:
npm install -g mean-cli
npm install (inside project folder)
My issue was resolved. Hope this helps someone else.
I just removed and re-installed and everything worked. Go figure. I also had to use sudo because I'm on a mac.
sudo npm install -g ember-cli#2.5
The problem is when you install config-chain it installs in your project directory node_modules but cordova add browser is looking in global modules. This is what I did, went outside the directory and ran npm install -g config-chain That resolved this module and asked for more do the same thing for all modules it complains and you should be good.
I have centOS: When I try to run an node.js app that requires express, I get the following error:
module.js:340
throw err;
^
Error: Cannot find module 'express'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/var/www/tipsterPro/index.js:2:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
I verified that express is in the node_modules directory:
root#myServer [/usr/local/lib/node_modules]# ls
./ ../ express/ express-generator/ forever/ n/ npm/ pm2/ supervisor/
I found a couple of postings stating to install express in the top directory of the node.js project. Is there a way to not have to install express in every project I have? There should be a way to point it to the install directory.
Additional info:
I installed node and express globally.
I also installed express-generator using: npm install -g express-generator.
BTW: node modules are installed in this location (not sure if correct): /usr/local/lib/node_modules
I ended up installing locally, after some reading about pros and cons of express local versus global installation it might be better if I install express locally. Once I installed locally it ran successfully.
The node module lookup algorithm looks like this (from Node.js in Action):
So if you have the module installed in node_modules at the root directory of your project, it will be found in every subdirectory and file. As you can see at the last point of the diagram, you can specify a search directory by setting the NODE_MODULES environment variable. When you globally install express it may be located somewhere like /usr/local/bin/express. You could set the NODE_MODULES directory when launching your app using
NODE_MODULES=/usr/local/bin/ node app.js
As you have guessed, there is indeed a solution to your issue.
You need to install express globally. That is instead of running npm install express you run:
sudo npm install -g express
The sudo is needed to get write access to the global location.
Flag -g stands for global installation. You can use it on any module.
This is not panacea though, some projects might require very specific versions, thus having a single install is not an option. For such projects you still have to install express locally for the project. But in your case, I believe having a global install is sufficient.
Node searches upward in the directory hierarchy for packages.
An absurd answer is to do this
# cd /
# npm install express
That will set up /node_modules ...
Today, I get strange thing that after i install async in global, nodejs reports it can not find the module.following is the workflow
install async
npm install -g async
make sure async exists
npm list -g async
get this output:
/usr/local/lib
├── async#0.2.9
└─┬ npm#1.3.21
└─┬ request#2.30.0
└─┬ form-data#0.1.2
└── async#0.2.9
3.try to use it.
I create a simple js file which only contains one statement:
var async=require('async');
then execute the file via node, I get exception:
Error: Cannot find module 'async'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (/lxzhu/nodejs/asynctest/test.js:1:73)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
It is because you are installing async globally.
npm install async will put create a directory called node_modules, and the require lookup algorithm will find it there.
A global installation of an NPM doesn't always mean that the module can be shared for multiple projects. This is a pretty popular misconception. You can read this blog post on nodejs.org for more information, but generally speaking, global modules are used for command line tools and other system utilities, not for modules to be used in your code.
So, ideally, you would need the modules locally for each of your projects.
async installed globally. For that we have to create and install modules of async.
npm install async --save
This command line add files in node_modules folder.
This worked for me:
npm uninstall async
npm install -g async
npm link async
One way of using globally installed modules in multiple projects is to use the npm link command
npm link will create a symlink of the globally installed package into your apps node_modules directory
if dont Find Any Module like
Cannot find module 'sql' , Cannot find module 'nodemailer'
then use npm install and module name which is can not found.
npm install async
Finally, i get answer from http://nodejs.org/api/modules.html.
After install globally, i need to put its subdirectory to NODE_PATH to make it appears in node's search path.
Also, as the document said, It is suggested to store module locally and NODE_PATH is for version compatibility and we should not use it any more.