I have the following files:
Cakefile:
require './test'
test.coffee:
console.log 'hi'
another_test.coffee:
require './test'
If I run cake, I get the following exception:
module.js:340
throw err;
^
Error: Cannot find module './test'
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> (/Users/jose/Desktop/Cakefile:2:3)
at Object.<anonymous> (/Users/jose/Desktop/Cakefile:4:4)
at Module._compile (module.js:456:26)
However, if I run coffee another_test.coffee, I get this output:
hi
I installed node using brew and coffee-script using npm, and am using the following versions:
$ node -v
v0.10.24
$ npm -v
1.3.21
$ coffee -v
CoffeeScript version 1.7.1
Why can't Cakefile require test.coffee?
Solved by adding:
require 'coffee-script/register'
on top of Cakefile. See: https://stackoverflow.com/a/21678007/347915
Have you tried using an absolute path ? Try this instead :
require "#{__dirname}/test"
Related
I try to execute the node kline command, but it gives me an error:
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\kline'
←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)←[39m
←[90m at Function.Module._load (internal/modules/cjs/loader.js:725:27)←[39m
←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)←[39m
←[90m at internal/main/run_main_module.js:17:47←[39m {
code: ←[32m'MODULE_NOT_FOUND'←[39m,
requireStack: []
}
Although npm install kline was successful. Tell me, maybe I missed something.
From what I gathered the kline module doesn't seem to be designed for the command line. Besides this to install a package which should run from the command line, e.g. nodemon, you should add the -g flag to the npm install command. This will install your package in the global npm scope which also supports calling these packages as a command, if supported.
Inprocess to setup local PWA locally, I created environment.local.ts file with local configuration and tried to start PWA using command ng s -c local and now getting below error.
Please suggest !
WARNING in
./node_modules/#wishtack/reactive-component-loader/dist/reactive-component-loader/fesm5/wishtack-reactive-component-loader.js
226:65-83 "export 'ɵɵdefineInjectable' was not found in
'#angular/core'
WARNING in
./node_modules/#wishtack/reactive-component-loader/dist/reactive-component-loader/fesm5/wishtack-reactive-component-loader.js
226:175-183 "export 'ɵɵinject' was not found in '#angular/core'
WARNING in
./node_modules/#wishtack/reactive-component-loader/dist/reactive-component-loader/fesm5/wishtack-reactive-component-loader.js
226:195-203 "export 'ɵɵinject' was not found in '#angular/core'
WARNING in
./node_modules/#wishtack/reactive-component-loader/dist/reactive-component-loader/fesm5/wishtack-reactive-component-loader.js
226:215-223 "export 'ɵɵinject' was not found in '#angular/core'
WARNING in
./node_modules/#wishtack/reactive-component-loader/dist/reactive-component-loader/fesm5/wishtack-reactive-component-loader.js
226:248-256 "export 'ɵɵinject' was not found in '#angular/core'
ERROR in ./src/styles.scss Module build failed (from
./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleBuildError: Module build failed (from
./node_modules/sass-loader/lib/loader.js): Error: Node Sass does not
yet support your current environment: Windows 64-bit with Unsupported
runtime (79) For more information on which environments are supported
please see: https://github.com/sass/node-sass/releases/tag/v4.12.0
at module.exports (C:\ProgressiveWebApp\pwa\node_modules\node-sass\lib\binding.js:13:13)
at Object. (C:\ProgressiveWebApp\pwa\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
at Module.load (internal/modules/cjs/loader.js:914:32)
at Function.Module._load (internal/modules/cjs/loader.js:822:14)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.sassLoader (C:\ProgressiveWebApp\pwa\node_modules\sass-loader\lib\loader.js:46:72)
at C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\NormalModule.js:301:20
at C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:367:11
at C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:233:18
at runSyncOrAsync (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:143:3)
at iterateNormalLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
at C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:205:4
at VirtualFileSystemDecorator.readFile (C:\ProgressiveWebApp\pwa\node_modules#ngtools\webpack\src\virtual_file_system_decorator.js:39:13)
at processResource (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:202:11)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:158:10)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:165:10)
at C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:176:18
at loadLoader (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\loadLoader.js:47:3)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:169:2)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:165:10)
at C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:176:18
at loadLoader (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\loadLoader.js:47:3)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:169:2)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:165:10)
at C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:176:18
at loadLoader (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\loadLoader.js:47:3)
at iteratePitchingLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:169:2)
at runLoaders (C:\ProgressiveWebApp\pwa\node_modules\loader-runner\lib\LoaderRunner.js:365:2)
at NormalModule.doBuild (C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\NormalModule.js:280:3)
at NormalModule.build (C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\NormalModule.js:427:15)
at Compilation.buildModule (C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\Compilation.js:635:10)
at C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\Compilation.js:1021:12
at C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\NormalModuleFactory.js:405:6
at C:\ProgressiveWebApp\pwa\node_modules\webpack\lib\NormalModuleFactory.js:155:13
ERROR in
./src/app/shared/common/components/loading/loading.component.scss
Module build failed (from ./node_modules/sass-loader/lib/loader.js):
Error: Node Sass does not yet support your current environment:
Windows 64-bit with Unsupported runtime (79) For more information on
which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.12.0
at module.exports (C:\ProgressiveWebApp\pwa\node_modules\node-sass\lib\binding.js:13:13)
at Object. (C:\ProgressiveWebApp\pwa\node_modules\node-sass\lib\index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1103:10)
at Module.load (internal/modules/cjs/loader.js:914:32)
at Function.Module._load (internal/modules/cjs/loader.js:822:14)
at Module.require (internal/modules/cjs/loader.js:956:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.sassLoader (C:\ProgressiveWebApp\pwa\node_modules\sass-loader\lib\loader.js:46:72)
ERROR in ./node_modules/#wishtack/rx-scavenger/dist/scavenger.js
Module not found: Error: Can't resolve 'core-js/es/map' in
'C:\ProgressiveWebApp\pwa\node_modules#wishtack\rx-scavenger\dist'
ERROR in ./node_modules/#wishtack/rx-scavenger/dist/scavenger.js
Module not found: Error: Can't resolve
'core-js/modules/es.array.includes' in
'C:\ProgressiveWebApp\pwa\node_modules#wishtack\rx-scavenger\dist'
Thanks,
Mayank
Check the versions of node and npm by using:
node --version
npm --version
Compare with the required versions declared in package.json in the root folder of the project:
"engines": {
"node": ">=10.16.0",
"npm": "~6.9.0"
},
Update node or npm if necessary.
I am trying to upgrade from loopback 3 to loopback 4 using "mounting strategy" according to the documentation.
while trying to run the app using npm start, i am getting the following error:
node -r source-map-support/register .
Cannot start the application. { Error: Cannot find module
'../../node_modules/loopback-component-passport/lib/models/utils.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (C:\Data\myComp\app\myapp_docker\services\myapp_auth\lb3app\server\utils\providerUtils.js:2:15)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object. (C:\Data\myComp\app\myapp_docker\services\fauth\lb3app\server\server.js:6:25)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32) code: 'MODULE_NOT_FOUND' } npm ERR! code ELIFECYCLE npm ERR! errno 1
I checked and i have the module in the node_modules directory and the utils.js file.
I had to search in all my app files for the string "node_modules" and I found that the relative path for that directory was incorrect. had to add one more "../" before the node_modules.
We are trying to implement Report State API at github openhab project.
We are using “actions-on-google” version “2.6.0”.
We have added below lines to openhab.js file
const {smarthome} = require('actions-on-google');
const app = smarthome({
});
Please find the below console output:
smartfueb_march_gmail_com#instance-1-ubuntu16:/home/smartfueb_march/openhab-google-assistant/functions$ gcloud beta functions deploy openhabGoogleAssistant --stage-bucket smart_test1 --trigger-http
Deploying function (may take a while - up to 2 minutes)...failed.
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Code in file index.js can't be loaded.
Is there a syntax error in your code?
Detailed stack trace: TypeError: smarthome is not a function
at Object. (/user_code/openhab.js:23:13)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object. (/user_code/index.js:18:17)
at Module._compile (module.js:577:32)
We could resolve the issue of smarthome is not function by using below commands and changing the package.json file to 2.6.0.
$ sudo npm install -g actions-on-google#latest
Makefile - Content:
REPORTER = dot
all: build
build:
#./node_modules/coffee-script/bin/coffee \
-c \
-o lib src
clean:
rm -rf lib
mkdir lib
watch:
#./node_modules/coffee-script/bin/coffee \
-o lib \
-cw src
test:
#./node_modules/mocha/bin/mocha \
--reporter $(REPORTER) \
test/*.coffee
.PHONY: build clean watch test
The project root directory has a test folder with two files: mocha.opts and example.coffee
example.coffee - Content
describe "feature", ->
it "should add two numbers", ->
(2+2).should.equal 4
On running make test, getting the following error:
cribe 'feature',
^^^^^^^^^
node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
SyntaxError: Unexpected string
at Module._compile (module.js:429:25)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Module.require (module.js:354:17)
at require (module.js:370:17)
at /home/my_username/testcode/coffeepress/node_modules/mocha/bin/_mocha:261:27
at Array.forEach (native)
at load (/home/my_username/testcode/coffeepress/node_modules/mocha/bin/_mocha:258:9)
at Object.<anonymous> (/home/my_username/testcode/coffeepress/node_modules/mocha/bin/_mocha:249:1)
at Module._compile (module.js:441:26)
at Object..js (module.js:459:10)
at Module.load (module.js:348:31)
at Function._load (module.js:308:12)
at Array.0 (module.js:479:10)
at EventEmitter._tickCallback (node.js:192:40)
Running Mocha with js files succeeds, but cannot get it to run with CoffeeScript. I really want to - for code brevity.
Please guide.
As of Mocha 1.0:
coffee-script is no longer supported out of the box. CS and similar transpilers may be used by mapping the file extensions (for use with --watch) and the module name. For example --compilers coffee:coffee-script with CoffeeScript 1.6- or --compilers coffee:coffee-script/register with CoffeeScript 1.7+.
(Quoting http://visionmedia.github.io/mocha/#compilers-option) So, you need to add the line
--compilers coffee:coffee-script/register
or, for CS <= 1.6.x,
--compilers coffee:coffee-script
to your mocha.opts file.
From CoffeeScript 1.7 onwards, the option should be:
--compilers coffee:coffee-script/register
An issue was filed on Mocha's github site.
Apparently, a change in Mocha made in April 2018 (softly) deprecated the --compilers option. In the command line you now get:
(node:27864) DeprecationWarning: "--compilers" will be removed in a future version of Mocha; see https://git.io/vdcSr for more info
Like the link says, this can easily be fixed by just not using --compilers and using this new (simplified) mocha.opts options:
--require coffeescript/register
test/*.coffee
The last line is needed to make Mocha understand it should now use *.coffee files as test files. This seems not to be covered with the --require option.
mocha --require coffeescript/register
Source: https://github.com/mochajs/mocha/wiki/compilers-deprecation
with the latest update of mocha the the require statement must written in package.json file as
"mocha":{
"require":"coffeescript",
"reporter":"spec"
},
I needed two changes to my mocha args to get this to work:
--require coffee-script/register
--compilers coffee:coffee-script/register