I am attempting to use Babelify to transpile the async and await ES7 features but I don't wish to use gulp, grunt or similar build tools. Thus far, I have had great success using only npm, and this one extra step doesn't seem to be worth the trouble of adopting a more sophisticated build toolchain.
This is my minimal package.json file which works as long as I don't use async/await:
{
"main": "main.js",
"scripts": {
"compile": "browserify . --outfile bundle.js"
},
"browserify": {
"transform": [
[
"babelify",
{
"optional": [
"es7.asyncFunctions"
]
}
]
]
},
"devDependencies": {
"babelify": "^6.2.0",
"browserify": "^11.0.1"
}
}
And this is the small amount of code I'm attempting to transpile (main.js):
import "babelify/polyfill";
let asPromised = await fetch();
console.log(asPromised);
function fetch() {
return Promise.resolve("fetched");
}
And here is the unfortunate result when I execute npm run compile:
> # compile ~/project
> browserify . --outfile bundle.js
SyntaxError: ~/project/main.js: Unexpected token (3:23)
1 | import "babelify/polyfill";
2 |
> 3 | let asPromised = await fetch();
| ^
4 | console.log(asPromised);
5 |
6 | function fetch() {
at Parser.pp.raise (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/location.js:24:13)
at Parser.pp.unexpected (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/util.js:82:8)
at Parser.pp.semicolon (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/util.js:69:81)
at Parser.pp.parseVarStatement (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:371:8)
at Parser.pp.parseStatement (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:99:19)
at Parser.parseStatement (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/plugins/flow.js:621:22)
at Parser.pp.parseTopLevel (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/statement.js:30:21)
at Parser.parse (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/parser/index.js:70:17)
at Object.parse (~/project/node_modules/babelify/node_modules/babel-core/node_modules/babylon/lib/index.js:45:50)
at Object.exports.default (~/project/node_modules/babelify/node_modules/babel-core/lib/helpers/parse.js:36:18)
npm ERR! # compile: `browserify . --outfile bundle.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # compile script.
npm ERR! This is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! browserify . --outfile bundle.js
npm ERR! You can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 4.0.2-stable
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "run" "compile"
npm ERR! cwd ~/project
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! ~/project/npm-debug.log
npm ERR! not ok code 0
(gistified: https://gist.github.com/au-phiware/34376f64f9ea6777eefd)
I have also tried the following from the command line, which all give the same error:
browserify . --outfile bundle.js -t [ babelify --optional es7.asyncFunctions ]
babel --out-file bundle.js --optional es7.asyncFunctions main.js
babel --out-file bundle.js --stage 2 main.js
I feel as if I'm missing something here... or maybe this is a Babel bug?
TIA.
I feel as if I'm missing something here...
You can only use await inside async functions. For example:
async function foo() {
return await bar();
}
foo().then(x => console.log(x));
At the top level you always have to deal with the promise directly:
fetch().then(x => console.log(x));
Related
I need to create a jenkins job for publishing a package to npmjs.com. The package source code is in a github repository.
I successfully publish the package from my pc executing 'npm publish' command in console but facing an error using jenkins.
That is what i have in my jenkins job:
Specified path to the github project.
Added 'Execute Windows batch command'. The script:
git checkout master
git pull
npm publish
The console output:
C:\Program Files (x86)\Jenkins\workspace\js-agent-cucumber-release>git checkout master
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
(use "git pull" to update your local branch)
Previous HEAD position was fbd7040 Update package.json
Switched to branch 'master'
C:\Program Files (x86)\Jenkins\workspace\js-agent-cucumber-release>git pull
Updating 27de403..fbd7040
Fast-forward
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
C:\Program Files (x86)\Jenkins\workspace\js-agent-cucumber-release>npm publish
npm notice
npm notice package: reportportal-agent-cucumber#2.0.5
npm notice === Tarball Contents ===
npm notice 1.4kB package.json
npm notice 49B .eslintrc.js
npm notice 11.6kB LICENSE
npm notice 11.3kB README.md
npm notice 15.6kB modules/cucumber-epam-reportportal-handler.js
npm notice 191B modules/index.js
npm notice 1.3kB modules/loggerWorld.js
npm notice 267B testSample/config/rpConfig.json
npm notice 1.4kB testSample/cuceLaunch.js
npm notice 234B testSample/features/noStepDef.feature
npm notice 222B testSample/features/passed.feature
npm notice 285B testSample/features/scenarioOutline.feature
npm notice 362B testSample/features/step_definitions/support/handlers.js
npm notice 139B testSample/features/step_definitions/support/hooks.js
npm notice 748B testSample/features/step_definitions/support/world.js
npm notice 2.5kB testSample/features/step_definitions/waiting.js
npm notice 340B testSample/features/table.feature
npm notice 374B testSample/features/webDriverFailed.feature
npm notice 327B testSample/package.json
npm notice 820B testSample/protractor.conf.js
npm notice 291B testSample/protractor/features/failedProtractor.feature
npm notice 184B testSample/protractor/features/noSuchElementProtractor.feature
npm notice 217B testSample/protractor/features/protractor.feature
npm notice 954B testSample/protractor/features/step_definitions/protractorSteps.js
npm notice 368B testSample/protractor/features/step_definitions/support/handlers.js
npm notice 136B testSample/protractor/features/step_definitions/support/hooks.js
npm notice 216B testSample/protractor/features/step_definitions/support/world.js
npm notice 6B testSample/reports/report.json
npm notice === Tarball Details ===
npm notice name: reportportal-agent-cucumber
npm notice version: 2.0.5
npm notice package size: 15.3 kB
npm notice unpacked size: 51.9 kB
npm notice shasum: 478e6712549cfd3b0d472091409ef248625aa2e1
npm notice integrity: sha512-NpE2GRG6a9YV7[...]DdxhC8MtZbISA==
npm notice total files: 28
npm notice
npm ERR! path C:\WINDOWS\TEMP\npm-9528-4708d294\tmp\fromDir-47da48b4\package.tgz
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\WINDOWS\TEMP\npm-9528-4708d294\tmp\fromDir-47da48b4\package.tgz'
npm ERR! { [Error: EPERM: operation not permitted, unlink 'C:\WINDOWS\TEMP\npm-9528-4708d294\tmp\fromDir-47da48b4\package.tgz']
npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'C:\WINDOWS\TEMP\npm-9528-4708d294\tmp\fromDir-47da48b4\package.tgz'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'C:\\WINDOWS\\TEMP\\npm-9528-4708d294\\tmp\\fromDir-47da48b4\\package.tgz' },
npm ERR! isOperational: true,
npm ERR! stack:
npm ERR! 'Error: EPERM: operation not permitted, unlink \'C:\\WINDOWS\\TEMP\\npm-9528-4708d294\\tmp\\fromDir-47da48b4\\package.tgz\'',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'C:\\WINDOWS\\TEMP\\npm-9528-4708d294\\tmp\\fromDir-47da48b4\\package.tgz' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm-cache\_logs\2019-04-03T14_18_29_316Z-debug.log
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
Does any body know how to solve the problem ?
Finally I managed to create a pipeline for releasing my package to npmjs. Steps:
Create a jenkins job of the 'Pipeline' type.
In the section 'Pipeline' choose 'Pipeline script from SCM'.
Choose the repository type and add path to your repo.
Add a file called "Jenkinsfile" in the root of your project and put the below script into it.
pipeline {
agent {
docker {
image 'node:10-alpine'
args '-u root'
}
}
stages {
stage('Install') {
steps {
sh 'npm install'
}
}
stage('Publish') {
steps {
load "$JENKINS_HOME/jobvars.env"
withEnv(["TOKEN=${NPMJS_TOKEN}"]) {
sh 'echo "//registry.npmjs.org/:_authToken=${TOKEN}" >> ~/.npmrc'
sh 'npm publish'
}
}
}
}
}
Create a file called "jobvars.env" under the folder where the jenkins installed and
put the line into it:
NPMJS_TOKEN="token-generated-on-npmjs-com-in-your-profile"
I am trying to build my react library , and npm build gives this error . what is causing this error and how to fix it ?
src/lib/CircularProfiles.js -> dist/CircularProfiles.js
SyntaxError: src/lib/Github.js: Unexpected token (14:10)
12 | class GithubProfileBar extends Component {
13 |
> 14 | state = {
| ^
15 | totalRepos: 0,
16 | totalStars: 0,
17 | }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-profiles#0.1.0 build: `rm -rf dist && NODE_ENV=production babel src/lib --out-dir dist --copy-files --ignore __tests__,spec.js,test.js,__snapshots__`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-profiles#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/natesh/.npm/_logs/2018-12-26T03_51_21_931Z-debug.log
My .babelrc file :
{
"presets": [
"es2015",
"react"
]
}
I found that the error is because of older version of babel which doesn't handle newer versions of react code.
Here's the fix :
My problem was of older babel version fixed easily by installing:
npm i -D #babel/plugin-proposal-class-properties \
#babel/preset-react \
#babel/preset-env \
#babel/core \
#babel/plugin-transform-runtime \
In .babelrc file :
{
"presets": [
"#babel/react" ,
"#babel/env" ,
],
"plugins": [
"#babel/plugin-proposal-class-properties"
]
}
Now babel built it successfully after this.
Make sure you are not using both v7 and v6 branch og babel. The "#babel/core" is the 7x branch and the "babel/core" is the 6x branch, you should not have both installed at once!
When I run "npm install", it runs successfully and it installs all the packages in node_module folder. However when I run "npm start" command in cmd then it gives following errors.
D:\INSM-HTML-Player>npm start
insm-player#1.0.0 start D:\INSM-HTML-Player
npm run build && npm run serve | npm run watch
insm-player#1.0.0 build D:\INSM-HTML-Player
rollup -c && concat-cli -f dist/main.js -o dist/all.js && npm run compress
resolve failed: { Error: Cannot find module 'npm-watch'
at Function.Module._resolveFilename (module.js:469:15)
at Function.requireRelative.resolve (D:\INSM-HTML-Player\node_modules\requir e-relative\index.js:30:17)
at resolve (D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\seriali ze.js:25:26)
at findAndRemove (D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\s erialize.js:67:11)
at D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\serialize.js:111:13 at Array.map (native)
at loadPreset (D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\serialize.js:103:29)
at module.exports (D:\INSM-HTML-Player\node_modules\modify-babel-preset\inde x.js:97:19)
at Object.<anonymous> (D:\INSM-HTML-Player\node_modules\babel-preset-es2015-rollup\index.js:3:18)
at Module._compile (module.js:570:32) code: 'MODULE_NOT_FOUND' } npm-watch resolve failed: { Error: Cannot find module 'grunt-cli'
at Function.Module._resolveFilename (module.js:469:15)
at Function.requireRelative.resolve (D:\INSM-HTML-Player\node_modules\requir e-relative\index.js:30:17)
at resolve (D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\seriali ze.js:25: at findAndRemove (D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\s erialize.js:67:11)
at D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\serialize.js:111:13
at Array.map (native)
at loadPreset (D:\INSM-HTML-Player\node_modules\modify-babel-preset\lib\serialize.js:103:29)
at module.exports (D:\INSM-HTML-Player\node_modules\modify-babel-preset\index.js:97:19)
at Object.<anonymous> (D:\INSM-HTML-Player\node_modules\babel-preset-es2015-rollup\index.js:3:18)
at Module._compile (module.js:570:32) code: 'MODULE_NOT_FOUND' } gruntcli C:\Program Files\nodejs\node.exe D:\INSM-HTML-Player\node_modules\rollup\bin\rollup concat-cli -f string -o string
Options: -f, --files files or glob/wildcard to be matched and concatenated
[array] [required]
-o, --output the resulting file of the concatenation[string] [default: "all"]
--helpShow help [boolean]Examples: concat-cli -f *.js -o bundle.js This will concatenate all the js files in the current directory into a bundle.js Missing required argument: f
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe""C:\\ProgramFiles\\nodejs\\node_modules\\npm\\bin\\npm cli.js" "run" "build"
npm ERR! node v6.9.4
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! insm-player#1.0.0 build: `rollup -c && concat-cli -f dist/main.js o dist/all.js && npm run compress`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the insm-player#1.0.0 build script 'rollup -c && concat cli - f dist/main.js -o dist/all.js && npm run compress'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the insm-player package,
npm ERR! not with npm itself. npm ERR! Tell
the author that this fails on your system:
npm ERR! rollup -c &&
concat-cli -f dist/main.js -o dist/all.js && npm run c ompress npm
ERR! You can get information on how to open an issue for this project
with:
npm ERR! npm bugs insm-player npm ERR! Or if that isn't
available, you can get their info via: npm ERR! npm owner ls
insm-player
npm ERR! There is likely additional logging output
above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\INSM-HTML-Player\npm-debug.log
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\ node_modules\\npm\\bin\\npm-cli.js" "start" npm
ERR! node v6.9.4 npm ERR! npm v3.10.10 npm ERR! code ELIFECYCLE
npm ERR! insm-player#1.0.0 start: `npm run build && npm run serve |
npm run watch`
npm ERR! Exit status 1 npm ERR! npm ERR! Failed
at the insm-player#1.0.0 start script 'npm run build && npm run
serve | npm run watch'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the insm-player package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run build && npm run serve | npm run watch
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs insm-player
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls insm-player
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\INSM-HTML-Player\npm-debug.log
You have to add the missing package npm-watch to package.json:
npm install npm-watch --save-dev
The run npm start again.
Man is this a pain to setup! I've followed the installation instructions here clicking on the nodemon box:
https://babeljs.io/docs/setup/#installation
npm install babel-cli babel-preset-es2015 --save-dev
.babelrc in root directory:
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
package.json (I've installed more babel stuff as seen):
...
"devDependencies": {
"babel-cli": "^6.11.4",
"babel-core": "^6.13.2",
"babel-plugin-transform-async-to-generator": "^6.8.0",
"babel-polyfill": "^6.13.0",
"babel-preset-es2015": "^6.13.2",
"babel-preset-node6": "^11.0.0",
"babel-register": "^6.11.6"
},
"scripts": {
"startn": "nodemon app.js",
"babel-node": "babel-node --presets=es2015 --ignore='foo|bar|baz'",
"babel-dev": "nodemon --exec npm run babel-node -- experiment/socketio/test.js"
},
...
test.js:
(async function () { // <-- error occues here
const value = await 123;
console.log(value);
})().then(() => {
console.log('Done');
});
I run the command run-script babel-dev as seen below. Error:
karl#karl-ux303ln:~/dev/sketch$ npm run-script babel-dev
> sketch#0.0.1 babel-dev /home/karl/dev/sketch
> nodemon --exec npm run babel-node -- experiment/socketio/test.js
[nodemon] 1.10.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `npm run babel-node experiment/socketio/test.js`
> sketch#0.0.1 babel-node /home/karl/dev/sketch
> babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"
/home/karl/dev/sketch/node_modules/babel-core/lib/transformation/file/index.js:591
throw err;
^
SyntaxError: /home/karl/dev/sketch/experiment/socketio/test.js: Unexpected token (1:7)
> 1 | (async function () {
| ^
2 | const value = await 123;
3 | console.log(value);
4 | })().then(() => {
at Parser.pp.raise (/home/karl/dev/sketch/node_modules/babylon/lib/parser/location.js:22:13)
at Parser.pp.unexpected (/home/karl/dev/sketch/node_modules/babylon/lib/parser/util.js:89:8)
at Parser.pp.expect (/home/karl/dev/sketch/node_modules/babylon/lib/parser/util.js:83:33)
at Parser.pp.parseParenAndDistinguishExpression (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:582:12)
at Parser.pp.parseExprAtom (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:481:19)
at Parser.pp.parseExprSubscripts (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:277:19)
at Parser.pp.parseMaybeUnary (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:257:19)
at Parser.pp.parseExprOps (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:188:19)
at Parser.pp.parseMaybeConditional (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:165:19)
at Parser.pp.parseMaybeAssign (/home/karl/dev/sketch/node_modules/babylon/lib/parser/expression.js:128:19)
npm ERR! Linux 3.19.0-65-generic
npm ERR! argv "/home/karl/.nvm/versions/node/v6.2.0/bin/node" "/home/karl/.nvm/versions/node/v6.2.0/bin/npm" "run" "babel-node" "experiment/socketio/test.js"
npm ERR! node v6.2.0
npm ERR! npm v3.8.9
npm ERR! code ELIFECYCLE
npm ERR! sketch#0.0.1 babel-node: `babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sketch#0.0.1 babel-node script 'babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sketch package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! babel-node --presets=es2015 --ignore='foo|bar|baz' "experiment/socketio/test.js"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sketch
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sketch
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/karl/dev/sketch/npm-debug.log
[nodemon] app crashed - waiting for file changes before starting...
I've also tried switching to node v4.4.7 and upgrading npm to 3.10.6. still same error.
1) remove all babel modules (remove everything, this is a little buggy I've found out)
2) install the following:
npm install --save-dev babel-polyfill babel-preset-es2015 babel-preset-stage-3 babel-register
3) fix .babelrc file:
{
"presets": [
"es2015",
"stage-3"
]
}
4) check to see if it works (-r flag is to preload modules):
node -r babel-register -r babel-polyfill experiment/socketio/test.js
To fix nodemon:
nodemon -r babel-register -r babel-polyfill experiment/socketio/test.js
Async/await is handled in babeljs by the plugin transform-async-to-generator, which is included in the stage-3 preset. It's not included by default in the es2015 preset, so you'll have to add either the plugin itself or the stage-3 preset explicitly. To do that on the command line, change this line in package.json:
"babel-node": "babel-node --presets=es2015 --ignore='foo|bar|baz'",
to read:
"babel-node": "babel-node --presets=es2015,stage-3 --ignore='foo|bar|baz'",
adding the stage-3 preset. The same could also be achieved like so:
"babel-node": "babel-node --presets=es2015 --plugins=transform-async-to-generator --ignore='foo|bar|baz'",
However, it's generally recommended practice to use the .babelrc configuration file, which could be as simple as:
{
"presets": ["es2015", "stage-3"]
}
or
{
"presets": ["es2015"],
"plugins": ["transform-async-to-generator"]
}
and then the line in your package.json could just be:
"babel-node": "babel-node --ignore='foo|bar|baz'",
(original answer for comment context)
You need to add:
"plugins": ["transform-async-to-generator"]
to your .babelrc, as I don't believe async/await is included in any of the standard presets (since it can be implemented in multiple ways)
This really puzzles me. Basically I set up a Go app that uses Grunt for the webapp.
I've use https://github.com/ddollar/heroku-buildpack-multi for my buildpack to combine nodejs and go buildpack and I couldn't get the nodejs buildpack to work.
I managed to install grunt and while executing my grunt task it just fails to get the module. Output from Heroku below:
Fetching repository, done.
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 1.23 KiB | 0 bytes/s, done.
Total 10 (delta 6), reused 0 (delta 0)
-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-nodejs.git
=====> Detected Framework: Node.js
-----> Requested node range: 0.10.x
-----> Resolved node version: 0.10.30
-----> Downloading and installing node
-----> Exporting config vars to environment
-----> Installing dependencies
npm WARN optional dep failed, continuing fsevents#0.2.0
> blat#0.0.0 postinstall /tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d
> echo postinstall time ls react; ls ./node_modules/react; echo AAA; ./node_modules/grunt-cli/bin/grunt heroku:deploy
postinstall time ls react
README.md
addons.js
dist
lib
node_modules
package.json
react.js
AAA
Loading "Gruntfile.js" tasks...ERROR
>> Error: Cannot find module 'React'
Warning: Task "heroku:deploy" not found. Use --force to continue.
Aborted due to warnings.
npm ERR! blat#0.0.0 postinstall: `echo postinstall time ls react; ls ./node_modules/react; echo AAA; ./node_modules/grunt-cli/bin/grunt heroku:deploy`
npm ERR! Exit status 3
npm ERR!
npm ERR! Failed at the blat#0.0.0 postinstall script.
npm ERR! This is most likely a problem with the blat package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! echo postinstall time ls react; ls ./node_modules/react; echo AAA; ./node_modules/grunt-cli/bin/grunt heroku:deploy
npm ERR! You can get their info via:
npm ERR! npm owner ls blat
npm ERR! There is likely additional logging output above.
npm ERR! System Linux 3.8.11-ec2
npm ERR! command "/tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d/vendor/node/bin/node" "/tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d/vendor/node/bin/npm" "install" "--userconfig" "/tmp/build_7d4b99cb-602b-42ee-9
a85-8b929a54646d/.npmrc" "--production"
npm ERR! cwd /tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d
npm ERR! node -v v0.10.30
npm ERR! npm -v 1.4.21
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /tmp/build_7d4b99cb-602b-42ee-9a85-8b929a54646d/npm-debug.log
npm ERR! not ok code 0
Note that I purposely call ls ./node_modules/react to see if it's installed and it is. But for some reason it can't find it on my node file.
My Gruntfile:
module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-react')
grunt.loadNpmTasks('grunt-browserify')
// doing this for testing - fails on heroku
var react= require('React')
grunt.initConfig({
browserify: {
options: {
transform: [require('grunt-react').browserify]
},
app: {
src: 'src/app.react.js',
dest: 'public/index.js'
}
},
})
grunt.registerTask('heroku:deploy', [
'browserify:app'
])
}
And package.json file:
{
"name": "blat",
"version": "0.0.0",
"description": "",
"engines": {
"node": "0.10.x",
"npm": "1.4.x"
},
"dependencies": {
"director": "^1.2.3",
"es6-promise": "^1.0.0",
"grunt": "^0.4.5",
"grunt-cli": "^0.1.13",
"grunt-react": "^0.9.0",
"react": "^0.11.1",
"react-router": "^0.5.2",
"superagent": "^0.18.2",
"superagent-prefix": "0.0.2"
},
"devDependencies": {},
"scripts": {
"postinstall": "echo postinstall time; ./node_modules/grunt-cli/bin/grunt heroku:deploy"
}
}
.buildpacks
https://github.com/heroku/heroku-buildpack-nodejs.git
https://github.com/kr/heroku-buildpack-go.git
Heroku config:
BUILDPACK_URL = https://github.com/ddollar/heroku-buildpack-multi.git
NODE_ENV = production
Does anyone know what the problem is? I can't reproduce it locally and it's so frustrating. I've tried https://github.com/mbuchetics/heroku-buildpack-nodejs-grunt buildpack but it gives me the same result..
Ok turns out it was case sensitive issue. Apparently I was using HFS+ case insensitive format which explains why my code was working locally..