As the title says, babel --out-file-extension doesn't work.
Here is package.json :
{
"name": "Assets",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"babel:dev": "babel --presets es2015 Scripts/src -d Scripts/js",
"babel:min": "babel --presets minify Scripts/src -d Scripts/js --out-file-extension .min.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.3",
"babel-preset-es2015": "^6.24.1",
"babel-preset-minify": "^0.5.1"
}
}
When I run npm run babel:dev the result is : Scripts\src\main.js -> Scripts\js\main.js
But the same result happens when I run npm run babel:min, out files are minified but the extension won't change.
So What am I doing wrong here?
If you look at the docs for --out-file-extension, it states
Added in: v7.8.0
You are using Babel 6.x, so that option is not available.
Related
I got that error “react doesn't exist” when I'm trying to compile jsx using babel using this command :
npx babel src/index.js --out-file=public/main.js --presets=env,react
both dependencies env and react are configured.
{"name": "React",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"},
"keywords": [],
"author": "",
"license": "ISC"}
any ideas?
Do you add React?
yarn add react
or
npm install react
maybe try add this to script in package.json
{"name": "React",
"version": "1.0.0",
"description": "",
"main": "index.js",
"dependencies": {
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "babel src/index.js --out-file=public/main.js --presets=env,react"
},
"keywords": [],
"author": "",
"license": "ISC"}
And run command:
yarn dev
or
npm run dev
I'm trying to use netlify and its lambda function feature to run a node function. Based on https://css-tricks.com/using-netlify-forms-and-netlify-functions-to-build-an-email-sign-up-widget/.
I'm having trouble getting node modules to work (see ImportModuleError","errorMessage":"Error: Cannot find module while using Netlify lambda functions with dependencies)
Currently my netlify.toml has only the following:
[build]
functions = "./functions"
command = "npm run-script build"
and my package.json:
{
"name": "test2",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "npm install && npm build"
},
"repository": {
"type": "git",
"url": "git+https://github.com/kc1/test2.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/kc1/test2/issues"
},
"homepage": "https://github.com/kc1/test2#readme",
"dependencies": {
"dotenv": "^8.2.0",
"node-fetch": "^2.6.1"
}
}
You can see the deploy log here: https://app.netlify.com/sites/inspiring-ardinghelli-4a4da5/deploys/5fd180d4db83b400073f8694. What am I doing wrong?
I have exactly the same issue as User daffodils. When uploaded to heroku the app fails with a message "npm ERR! missing script: start" But I don't have a start command in my package.json and I do have "web : node app.js" in my Procfile
I don't have a start in my package.json file and the same file worked ok for another similar app on heroku:
{
"name": "tBlogv3withdb",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"engines": {
"node": "13.12.0"
},
"dependencies": {
"body-parser": "^1.18.3",
"ejs": "^2.6.1",
"express": "^4.16.3",
"lodash": "^4.17.15",
"mongoose": "^5.9.10"
}
}
User Daffodils said "I dropped the repo and re-init solved it." - what does this mean exactly?
I have created a basic todo app which has package.json file as:
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}
Whenever I run npm test it fails by saying no tests specified, how can I solve this issue? also whenever I try to use TRAVIS CI it fails to detect build script how can I create one?
Specify all required script in scripts property in package.json as below
{
"name": "to-do-app",
"version": "1.0.0",
"description": "A basic to-do app created using JavaScript.",
"main": "index.js",
"scripts": {
"test": "put test command here", // example "test": "mocha test.js"
"build" : "put build command here"
},
"author": "Sahil Silare",
"license": "MIT",
"dependencies": {
"body-parser": "^1.19.0",
"build": "^0.1.4",
"ejs": "^2.7.1",
"express": "^4.17.1",
"npm-build": "0.0.1"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://github.com/sahil9001/to-do-app.git"
},
"keywords": [
"todo",
"app"
],
"bugs": {
"url": "https://github.com/sahil9001/to-do-app/issues"
},
"homepage": "https://github.com/sahil9001/to-do-app#readme"
}
You don't have any scripts command listed in scripts property and have only default. You have to create and place it as per the need. Refer below links for more details
https://www.freecodecamp.org/news/introduction-to-npm-scripts-1dbb2ae01633/
https://flaviocopes.com/package-json/
If you look under "scripts" you'll see your npm scripts such as the script you call when you run "npm test"
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
The default value when you run NPM init is this simple echo saying no tests, you have to write your own test command(s) here.
Travis is failing to detect a build script, because you don't have a value for "build" in your scripts section, add something like:
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "my_script_to_build"
},
{
"name": "typescript-example",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"compile": "./node_modules/.bin/tsc.cmd --outDir ./build --module commonjs ./src/*.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^3.0.1"
}
}
Project structure:
-project
-src
-main.ts
-node_modules
-.bin
-tsc
-tsc.cmd
-tsserver
-tsserver.cmd
-typescript
...
-package.json
-tsconfig.json
Command: npm run compile
Error: error TS6053: File 'src/*.ts' not found.
I don't want to install typescript globally.