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
Related
So I have some aws swift lambdas that I deployed via sam deploy. That works fine.
The swift lambda looks like this: aws-samples
I am currently in the middle of building a CI/CD pipeline using Codepipeline and Codebuild. My Codebuild project executes the following buildspec.yml and is configured to cache to S3:
version: 0.2
phases:
build:
commands:
- sam build
- sam package -t template.yml --s3-bucket bucketName --output-template-file packaged.yaml
artifacts:
files:
- packaged.yaml
cache:
paths:
- ".aws-sam/**/*"
To build the swift lambdas sam buildexecuted the following makefile as the function in template.yml is set to: BuildMethod: makefile
Makefile:
### Add functions here and link them to builder-bot format MUST BE "build-FunctionResourceName in template.yaml"
build-ExpiredMediaItemProcessorLambda: builder-bot
builder-bot:
$(eval $#PRODUCT = $(subst build-,,$(MAKECMDGOALS)))
$(eval $#BUILD_DIR = $(PWD)/.aws-sam/build-$($#PRODUCT))
$(eval $#STAGE = $($#BUILD_DIR)/lambda)
$(eval $#ARTIFACTS_DIR = $(PWD)/.aws-sam/build/$($#PRODUCT))
# prep directories
mkdir -p $($#BUILD_DIR)/lambda $($#ARTIFACTS_DIR)
# Compile application
swift build --product $($#PRODUCT) -c release --build-path $($#BUILD_DIR)
# copy deps
ldd '/$($#BUILD_DIR)/release/$($#PRODUCT)' | grep swift | cut -d' ' -f3 | xargs cp -Lv -t /$($#BUILD_DIR)/lambda
# copy binary to stage
cp $($#BUILD_DIR)/release/$($#PRODUCT) $($#BUILD_DIR)/lambda/bootstrap
# copy app from stage to artifacts dir
cp $($#STAGE)/* $($#ARTIFACTS_DIR)
I got the makefile from the linked aws-samples project above which I modified slightly to work on codebuild.
Now to my question: How do I get codebuild S3 cache to work with swift lambdas?
when I cache the .aws-sam/**/* folder swift cannot compile because the build paths are different due to the different build machines. The error looks like so:
swift build --product LambdaName -c release --build-path /codebuild/output/src409372700/src/.swift-build/build-LambdaName
33 [1/863] Compiling CSotoExpat xmltok_impl.c
34 [2/863] Compiling CSotoExpat xmltok_ns.c
35 [3/865] Compiling INIParser INIParser.swift
36 <unknown>:0: error: PCH was compiled with module cache path '.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB', but the path is currently '/codebuild/output/src409372700/src/.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB'
37 <unknown>:0: error: missing required module 'SwiftShims'
38 [4/865] Compiling Logging Locks.swift
39 <unknown>:0: error: PCH was compiled with module cache path '.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB', but the path is currently '/codebuild/output/src409372700/src/.aws-sam/build-LambdaName/x86_64-unknown-linux-gnu/release/ModuleCache/1LD7OVICEM9JB'
40 <unknown>:0: error: missing required module 'SwiftShims'
As far as I understand this is due to the fact that swift build cannot cope with a changing or relative path.
After some digging I found this stack overflow post which has a similar problem. I tried there solution and the swift compile error is gone but after a rebuild swift compiles the entire project again even if no code was changed.
Any help is much appreciated!
Thanks!
What should I change in order to install the module? php is 5.3.3 withyum install php-devel in place.
PHP.c: In function ‘PHP_set_php_input’:
PHP.c:818: warning: passing argument 2 of ‘Perl_sv_2pv_flags’ from incompatible pointer type
/home/mpapec/.plenv/versions/5.20.0/lib/perl5/5.20.0/x86_64-linux/CORE/proto.h:3931: note: expected ‘STRLEN * const’ but argument is of type ‘int *’
cc -c -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -Wall -O2 -DVERSION=\"0.15\" -DXS_VERSION=\"0.15\" -fPIC "-I/home/mpapec/.plenv/versions/5.20.0/lib/perl5/5.20.0/x86_64-linux/CORE" array.c
In file included from /usr/include/php/main/php.h:33,
from /usr/include/php/sapi/embed/php_embed.h:23,
from PHP.h:14,
from array.c:9:
/usr/include/php/main/php_config.h:2417:1: warning: "_GNU_SOURCE" redefined
In file included from /home/mpapec/.plenv/versions/5.20.0/lib/perl5/5.20.0/x86_64-linux/CORE/perl.h:28,
from PHP.h:9,
from array.c:9:
/home/mpapec/.plenv/versions/5.20.0/lib/perl5/5.20.0/x86_64-linux/CORE/config.h:1825:1: warning: this is the location of the previous definition
rm -f blib/arch/auto/PHP/PHP.so
cc -shared -O2 -L/usr/local/lib -fstack-protector PHP.o array.o -o blib/arch/auto/PHP/PHP.so \
\
chmod 755 blib/arch/auto/PHP/PHP.so
"/home/mpapec/.plenv/versions/5.20.0/bin/perl5.20.0" -MExtUtils::Command::MM -e 'cp_nonempty' -- PHP.bs blib/arch/auto/PHP/PHP.bs 644
Manifying 1 pod document
Running Mkbootstrap for PHP ()
chmod 644 "PHP.bs"
PERL_DL_NONLAZY=1 "/home/mpapec/.plenv/versions/5.20.0/bin/perl5.20.0" "-Iblib/lib" "-Iblib/arch" test.pl
1..79
not ok 1 - use_ok PHP
# Failed test 'use_ok PHP'
# at test.pl line 11.
not ok 2 - require PHP;
# Failed test 'require PHP;'
# at test.pl line 18.
# Tried to require 'PHP'.
# Error: Attempt to reload PHP.pm aborted.
# Compilation failed in require at (eval 6) line 2.
not ok 3 - eval
# Failed test 'eval'
# at test.pl line 49.
Module PHP failed to load at blib/lib/PHP.pm line 80.
Module PHP failed to load at blib/lib/PHP.pm line 80.
END failed--call queue aborted at test.pl line 50.
# Looks like you planned 79 tests but ran 3.
# Looks like you failed 3 tests of 3 run.
# Looks like your test exited with 22 just after 3.
make: *** [test_dynamic] Error 22
-> FAIL Installing PHP failed. See /home/mpapec/.cpanm/work/1440522239.12833/build.log for details. Retry with --force to force install it.
(
PHP is kind of fragile. It probably won't work out of the box with your system php installation, and may have trouble with 64-bit or multi-threaded versions of perl.
I have only ever gotten it to work on Linux. The latest version I have tried to use is 5.3.8 (back in 2013), though I remember things going smoothly from 5.2.x to 5.3.8.
I always build php from source, with this configuration:
./configure --enable-embed --with-zlib --with-openssl --with-mysql \
--with-libdir=lib/i386-linux-gnu
--enable-embed is absolutely required, as the pod mentions, to build a PHP interpreter with the SAPI extension, and which then allows perl to manipulate the PHP interpreter through XS code. The other extensions were for other requirements of my project; they may be optional, but I haven't experimented with building the PHP interpreter or the PHP module with any other configuration. The pod also says to never use the --with-apxs argument, which I was never tempted to do anyway.
The build process of the PHP module will look for and require a program called php-config. You may need to hack your $PATH, if only during the build process, so that the PHP module runs the correct php-config. After that the module will know where to look for the rest of your php installation.
I had fun working with this module for a while (writing a Catalyst and then a Mojolicious wrapper around WordPress), but it has fallen into disrepair and disrepute. Share whatever you learn trying to build it and we'll put it in the docs, making this module that much easier to use.
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"
I'm trying to setup nodejs to access a postgres database. What I've done so far is the following (https://gist.github.com/579814):
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
then
git clone git://github.com/isaacs/npm.git
make
make install
so far, so good. However, when I try to install the postgres driver
npm install pg
I get the following:
node-waf configure build || true
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
Checking for program pg_config : /usr/bin/pg_config
'configure' finished successfully (0.066s)
Waf: Entering directory `/home/christian/node_modules/pg/build'
[1/2] cxx: src/binding.cc -> build/default/src/binding_1.o
../src/binding.cc:3:25: fatal error: node_events.h: No such file or directory
compilation terminated.
Waf: Leaving directory `/home/christian/node_modules/pg/build'
Build failed: -> task failed (err #1):
{task: cxx binding.cc -> binding_1.o}
I've been looking around for setting the node path, although haven't found anything of help so far - probably also because I'm totally new to nodejs, so I'd be happy about any hint.
Now, you have NodeJS installed in your Ubuntu. You should set /etc/environment and load nodeJS path that can be executed by another users. For example:
NODE="/home/ubuntu/local/node"
NODE_PATH="/usr/local/lib/node_modules"
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:$NODE/bin:$NODE/lib/node_modules"
#PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
Do this in bash:
echo 'export NODE_PATH=~/local/:~/local/node_modules' >> ~/.bashrc
before things are fixed you must use node 0.5.1 (you can use gitk to revert the tree to this version)
Auteur: Ryan Dahl <ry#tinyclouds.org> 2011-07-19 10:46:38
Auteur du commit: Ryan Dahl <ry#tinyclouds.org> 2011-07-19 10:46:38
Parent: 0a3fc1d9c8becc32c63ae736ca2b3719a3d03c5b (Remove StatWatcher's dep on C++ EventEmitter)
Enfant: 061ce7b0ac370c8a5ae93d95ab7da171cbd488f0 (net_uv: Fix simple/test-http-expect-continue.js)
Branche: master, remotes/origin/master
Suit: v0.5.1
Précède: v0.5.2
Finally remove node::EventEmitter
I had the same problem.
The issue was that I was specifying a old version of PG in my package.js
After I removed the old version dependancy I was able to install PG without issue.
I'm trying to make the node-mongodb-native driver from git, but when i try and install it i keep on getting this error:
:node-mongodb-native $ make
make -C ./external-libs/bson
rm -rf build .lock-wscript bson.node
node-waf configure build
Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /Users/name/local/node
'configure' finished successfully (0.087s)
Waf: Entering directory `/Users/name/Sites/git/node-mongodb-native/external-libs/bson/build'
[1/9] cxx: bson.cc -> build/default/bson_1.o
[2/9] cxx: long.cc -> build/default/long_1.o
[3/9] cxx: objectid.cc -> build/default/objectid_1.o
[4/9] cxx: binary.cc -> build/default/binary_1.o
[5/9] cxx: code.cc -> build/default/code_1.o
[6/9] cxx: dbref.cc -> build/default/dbref_1.o
[7/9] cxx: timestamp.cc -> build/default/timestamp_1.o
[8/9] cxx: local.cc -> build/default/local_1.o
[9/9] cxx_link: build/default/bson_1.o build/default/long_1.o build/default/objectid_1.o
build/default/binary_1.o build/default/code_1.o
build/default/dbref_1.o build/default/timestamp_1.o
build/default/local_1.o -> build/default/bson.node
Waf: Leaving directory `/Users/name/Sites/git/node-mongodb-native/external-libs/bson/build'
'build' finished successfully (1.935s)
node.js:183
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: dlopen(/Users/name/Sites/git/node-mongodb-native/external-libs/bson/build/default/bson.node, 1): Symbol not found: _ev_rt_now
Referenced from: /Users/name/Sites/git/node-mongodb-native/external-libs/bson/build/default/bson.node
Expected in: flat namespace
in /Users/name/Sites/git/node-mongodb-native/external-libs/bson/build/default/bson.node
at Object..node (module.js:472:11)
at Module.load (module.js:339:31)
at Function._load (module.js:298:12)
at require (module.js:367:19)
at Object.<anonymous> (/Users/name/Sites/git/node-mongodb-native/external-libs/bson/test_bson.js:5:10)
at Module._compile (module.js:427:26)
at Object..js (module.js:466:10)
at Module.load (module.js:339:31)
at Function._load (module.js:298:12)
at Array.<anonymous> (module.js:479:10)
make[1]: *** [all] Error 1
make: *** [build_native] Error 2
(some lines broken up for easier readability)
The suspicious part to me is this line:
Checking for node path : not found
I have this as my NODE_PATH in my ~/.bash_profile:
export NODE_PATH=/usr/local/lib/node_modules::/usr/local/lib/node
when I ls both of those directories, this is what i get:
$ ls /usr/local/lib/node
wafadmin -> ../../Cellar/node/0.4.8/lib/node/wafadmin
$ ls /usr/local/lib/node_modules
npm
I even just tried this as my NODE_PATH:
export NODE_PATH=/usr/local/lib/node_modules:/usr/local/lib/node:$HOME/local/node/lib/node_modules:$HOME/local/node/lib/node
which I don't think might be the best path b/c it has node installed in two locations which could lead to varying versions, but that's beside the point.
has anyone else had issues installing this driver?
NPM is the best choice to manage node related packages. If you already have npm, you just run npm install -g mongodb. It will install the node mongo driver into your global node_modules directory.
If you download and install node from its official website, npm will come by default.
Which version of node are you running? I was using v0.5.0-pre and I had this exact same error. Once I downgraded to v0.4.8 it worked.
brew install node
Or download v0.4.8 here