babel-preset-es2015-nostrict
raw JSON → 6.6.2 verified Sat Apr 25 auth: no javascript deprecated
A Babel preset that includes all ES2015 plugins but suppresses the automatic insertion of 'use strict' at the top of compiled modules. This is useful for projects that need to avoid strict mode globally (e.g., when concatenating scripts or using non-strict dependencies). The preset mirrors babel-preset-es2015 (v6.6.2) but without the strict-mode directive. It was released in 2015-2016 as part of the Babel 6 ecosystem. This package is now obsolete; Babel 7+ deprecates presets like this in favor of @babel/preset-env with the 'modules' and 'config' options. Key differentiator: removes strict-mode enforcement for legacy code compatibility.
Common errors
error Error: Cannot find module 'babel-preset-es2015-nostrict' ↓
cause The preset is not installed as a devDependency.
fix
Run 'npm install --save-dev babel-preset-es2015-nostrict'
error SyntaxError: Unexpected token import ↓
cause Babel is not configured to transform ES2015 modules, or the preset is not applied correctly.
fix
Ensure .babelrc contains { "presets": ["es2015-nostrict"] } and that babel-cli or babel-register is used.
Warnings
deprecated babel-preset-es2015-nostrict is deprecated in favor of using @babel/preset-env with the 'modules' option and appropriate config. ↓
fix Migrate to Babel 7+ and use @babel/preset-env. To disable strict mode, set 'modules' to 'false' or use 'loose' transforms.
breaking The preset does not include any polyfills; it only transforms syntax. You may need babel-polyfill for runtime features like Promise or Symbol. ↓
fix Add babel-polyfill as a separate import or use @babel/preset-env with useBuiltIns.
gotcha Without 'use strict', code may run in sloppy mode, which can expose differences in behavior (e.g., with this binding, reserved words). ↓
fix If you need strict mode in some files, consider splitting your build process or using the standard babel-preset-es2015.
Install
npm install babel-preset-es2015-nostrict yarn add babel-preset-es2015-nostrict pnpm add babel-preset-es2015-nostrict Imports
- preset wrong
// Wrong: require('babel-preset-es2015-nostrict') directly without using the preset stringcorrect// In .babelrc: { "presets": ["es2015-nostrict"] } - babel-preset-es2015-nostrict wrong
var preset = require('babel-preset-es2015-nostrict').default;correctrequire('babel-preset-es2015-nostrict') - babel-core (transform API) wrong
require('babel-core').transform(code, { presets: [require('babel-preset-es2015-nostrict')] })correctrequire('babel-core').transform(code, { presets: ['es2015-nostrict'] })
Quickstart
// 1. Install:
// npm install --save-dev babel-preset-es2015-nostrict babel-cli
// 2. .babelrc
{
"presets": ["es2015-nostrict"]
}
// 3. Run:
// babel script.js --out-file compiled.js
// Example input (ES2015):
const greet = name => `Hello, ${name}!`;
// Output (no 'use strict'):
var greet = function greet(name) {
return 'Hello, ' + name + '!';
};